mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-01-04 03:48:55 +02:00
update ndscheduler
This commit is contained in:
parent
b32329cd1c
commit
b6610a75ba
@ -6,15 +6,12 @@ FROM python:2-alpine
|
||||
MAINTAINER EasyPi Software Foundation
|
||||
|
||||
RUN set -xe \
|
||||
&& apk add --no-cache sqlite \
|
||||
&& pip install ndscheduler requests \
|
||||
&& rm -f /usr/local/lib/python2.7/site-packages/simple_scheduler/jobs/apns_job.py*
|
||||
&& apk add --no-cache bash sqlite \
|
||||
&& pip install ndscheduler requests
|
||||
|
||||
WORKDIR /opt/ndscheduler
|
||||
VOLUME /opt/ndscheduler
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
ENV NDSCHEDULER_SETTINGS_MODULE=simple_scheduler.settings
|
||||
|
||||
CMD ["python", "-c", "from ndscheduler.server.server import SchedulerServer; SchedulerServer.run()"]
|
||||
|
@ -4,4 +4,13 @@ ndscheduler
|
||||
[ndscheduler][1] is a flexible python library for building your own cron-like
|
||||
system, with REST APIs and a Web UI.
|
||||
|
||||
```bash
|
||||
$ mkdir -p data/jobs
|
||||
$ touch data/jobs/__init__.py
|
||||
$ wget -P data https://github.com/Nextdoor/ndscheduler/raw/v0.3.0/simple_scheduler/settings.py
|
||||
$ wget -P data/jobs https://github.com/Nextdoor/ndscheduler/raw/v0.3.0/simple_scheduler/jobs/shell_job.py
|
||||
$ docker-compose up -d
|
||||
$ curl http://127.0.0.1:8888
|
||||
```
|
||||
|
||||
[1]: https://github.com/Nextdoor/ndscheduler
|
||||
|
0
ndscheduler/data/jobs/__init__.py
Normal file
0
ndscheduler/data/jobs/__init__.py
Normal file
30
ndscheduler/data/jobs/shell_job.py
Normal file
30
ndscheduler/data/jobs/shell_job.py
Normal file
@ -0,0 +1,30 @@
|
||||
"""A job to run executable programs."""
|
||||
|
||||
from subprocess import call
|
||||
|
||||
from ndscheduler import job
|
||||
|
||||
|
||||
class ShellJob(job.JobBase):
|
||||
|
||||
@classmethod
|
||||
def meta_info(cls):
|
||||
return {
|
||||
'job_class_string': '%s.%s' % (cls.__module__, cls.__name__),
|
||||
'notes': ('This will run an executable program. You can specify as many '
|
||||
'arguments as you want. This job will pass these arguments to the '
|
||||
'program in order.'),
|
||||
'arguments': [
|
||||
{'type': 'string', 'description': 'Executable path'}
|
||||
],
|
||||
'example_arguments': '["/usr/local/my_program", "--file", "/tmp/abc", "--mode", "safe"]'
|
||||
}
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
return {'returncode': call(args)}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# You can easily test this job here
|
||||
job = ShellJob.create_test_instance()
|
||||
job.run('ls', '-l')
|
18
ndscheduler/data/settings.py
Normal file
18
ndscheduler/data/settings.py
Normal file
@ -0,0 +1,18 @@
|
||||
"""Settings to override default settings."""
|
||||
|
||||
import logging
|
||||
|
||||
#
|
||||
# Override settings
|
||||
#
|
||||
DEBUG = True
|
||||
|
||||
HTTP_PORT = 8888
|
||||
HTTP_ADDRESS = '0.0.0.0'
|
||||
|
||||
#
|
||||
# Set logging level
|
||||
#
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
JOB_CLASS_PACKAGES = ['jobs']
|
@ -6,4 +6,7 @@ services:
|
||||
- "8888:8888"
|
||||
volumes:
|
||||
- ./data:/opt/ndscheduler
|
||||
environment:
|
||||
- PYTHONPATH=/opt/ndscheduler
|
||||
- NDSCHEDULER_SETTINGS_MODULE=settings
|
||||
restart: unless-stopped
|
||||
|
Loading…
Reference in New Issue
Block a user