4 ms·
How do I define jobs? Can they be written in any language? I didn't see anything in the documentation.
by nodesocket 11y ago
How do I define jobs? Can they be written in any language? I didn't see anything in the documentation.
- kylequest 11y agoLooks like it's defined using the format you see in this json file: https://github.com/victorcoder/dcron/blob/master/job.json https://github.com/victorcoder/dcron/blob/master/job.json The "command" field is the most important part. What you put there gets executed like this by their agent (on Linux): /bin/sh -c <your_scheduled_command_name>
- andyeskridge 11y agoI was looking into that too. Based on this job.json[0] definition from the git repo, it looks like it just executes the command. So I believe you could have the job written in any language. But I think this also means you have to copy every job executable to every server that might have a chance of running the job. [0] https://github.com/victorcoder/dcron/blob/master/job.json https://github.com/victorcoder/dcron/blob/master/job.json
- victorcoder 11y agoAdded to the docs, big omission, sorry! http://dcron.io/docs/api/#create-or-update-a-job http://dcron.io/docs/api/#create-or-update-a-job
- nodesocket 11y agoAny change that dcron could manage the job scripts itself? I.E. you store the raw command scripts in dcon, then reference them in the create a job endpoint? For example: POST /scripts --data 'node /home/node/myJob.js' That returns a script id { "script_id": "507f1f77bcf86cd799439011" } Then: POST /jobs --data '{ "name":"cron_job", "schedule":"@every 2s", "script": "507f1f77bcf86cd799439011", "owner":"foo", "owner_email":"foo@bar.com" }' This way you don't have to manage/create the scripts on each node manually.
- victorcoder 11y agoI think you missed the point, jobs are stored in etcd so they're distributed and all dcron (server) nodes will see it. You can even create jobs from any node. Note that, non server nodes doesn't need access to etcd.