-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Martinez
committed
Sep 28, 2020
0 parents
commit 8feb475
Showing
36 changed files
with
3,344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
env: | ||
node: true | ||
es2020: true | ||
extends: | ||
- eslint:recommended | ||
- airbnb-base | ||
parserOptions: | ||
ecmaVersion: 11 | ||
sourceType: module | ||
rules: | ||
arrow-body-style: 'off' | ||
comma-dangle: 'off' | ||
import/no-unresolved: 'off' | ||
import/extensions: 'off' | ||
no-console: 'off' | ||
no-await-in-loop: 'off' | ||
no-loop-func: 'off' | ||
no-plusplus: 'off' | ||
no-multiple-empty-lines: 'off' | ||
no-underscore-dangle: 'off' | ||
lines-between-class-members: 'off' | ||
object-curly-newline: 'off' | ||
operator-linebreak: 'off' | ||
padded-blocks: 'off' | ||
prefer-arrow-callback: 'off' | ||
space-before-blocks: 'off' | ||
no-param-reassign: 'off' | ||
no-restricted-syntax: 'off' | ||
no-debugger: warn | ||
no-unused-vars: warn | ||
class-methods-use-this: warn | ||
eqeqeq: [error, allow-null] | ||
max-len: [error, 150] | ||
radix: [error, as-needed] | ||
arrow-parens: [error, as-needed, { requireForBlockBody: true }] | ||
no-shadow: | ||
- error | ||
- allow: [resolve, reject] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM node:14-alpine | ||
|
||
COPY . /opt/ckron | ||
RUN npm install --production -g /opt/ckron | ||
|
||
ENTRYPOINT [ "ckron" ] | ||
|
||
CMD ["daemon", "--config", "/etc/ckron/config.yml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
|
||
const commander = require('commander'); | ||
const Ckron = require('../lib/ckron'); | ||
const { version } = require('../package.json'); | ||
|
||
const program = new commander.Command(); | ||
|
||
program | ||
.version(version) | ||
.command('daemon') | ||
.option('--config <path>', 'configuration file', '/etc/ckron/config.yml') | ||
.action(async (cmd) => { | ||
try { | ||
const scheduler = new Ckron(); | ||
await scheduler.loadConfig(cmd.config); | ||
scheduler.start(); | ||
} catch (err) { | ||
console.error(err.message || err); | ||
process.exitCode = 1; | ||
} | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Job Reference | ||
|
||
## Job | ||
|
||
Schedule for a list of tasks | ||
|
||
| Property | Description | Required | | ||
|-|-|-| | ||
| [`schedule`](#schedule) | Cron-style job schedule | Yes | | ||
| [`timezone`](#timezone) | Timezone for schedule | No | | ||
| [`enabled`](#enabled) | When false job will not execute | No | | ||
| [`run_on_init`](#run_on_init) | Run job on start | No | | ||
| [`on_error`](#on_error) | List of notifier names to send task errors to | No | | ||
| [`tasks`](#tasks) | List of task names for this job | Yes | | ||
|
||
### **schedule** | ||
Cron-style job schedule. The main difference from the vanilla cron syntax is that the finest granularity is seconds instead of minutes. For more information checkout the [node-cron](https://github.com/kelektiv/node-cron#available-cron-patterns) documentation | ||
|
||
```yml | ||
schedule: '*/10 * * * * *' # Run every 10 seconds | ||
``` | ||
### **timezone** | ||
[IANA Timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to adjust the schedule time to. Default is to use the host time | ||
```yml | ||
timezone: America/Toronto | ||
``` | ||
### **enabled** | ||
When false job will not execute. Default value is *`true`* | ||
|
||
```yml | ||
enabled: false | ||
``` | ||
|
||
### **run_on_init** | ||
Run job on daemon startup. Default value is *`false`* | ||
|
||
```yml | ||
run_on_init: true | ||
``` | ||
|
||
### **on_error** | ||
List of notifier names to send task errors to | ||
|
||
```yml | ||
tasks: | ||
- notifier1 | ||
- notifier2 | ||
- notifier3 | ||
``` | ||
|
||
### **tasks** | ||
List of task names for this job. All tasks will be executed sequentially | ||
|
||
```yml | ||
tasks: | ||
- task1 | ||
- task2 | ||
- task3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Notifier Reference | ||
|
||
- [Email Notifier](#email-notifier) | ||
|
||
## Email Notifier | ||
|
||
Sends an emails | ||
|
||
| Property | Description | Required | | ||
|-|-|-| | ||
| [`smtp_host`](#smtp_host) | Hostname or IP address of the SMTP server | Yes | | ||
| [`smtp_port`](#smtp_port) | Port to connect to | No | | ||
| [`smtp_auth`](#smtp_auth) | SMTP server authentication | No | | ||
| [`from`](#from) | The email address of the sender | Yes | | ||
| [`to`](#to) | Recipients email addresses | Yes | | ||
|
||
|
||
### **smtp_host** | ||
Hostname or IP address of the SMTP server | ||
|
||
```yml | ||
smtp_host: smtp.example.com | ||
``` | ||
### **smtp_port** | ||
Port to connect to. Default value is `25` | ||
|
||
```yml | ||
smtp_port: 2525 | ||
``` | ||
|
||
### **smtp_auth** | ||
SMTP server authentication | ||
|
||
```yml | ||
smtp_auth: | ||
user: user | ||
pass: password | ||
``` | ||
|
||
### **from** | ||
The email address of the sender | ||
|
||
```yml | ||
from: '"Ckron Scheduler" <ckron@example.com>' | ||
``` | ||
|
||
### **to** | ||
Recipients email addresses | ||
|
||
```yml | ||
to: dev@example.com | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Task Reference | ||
|
||
- [Run Task](#run-task) | ||
- [Exec Task](#exec-task) | ||
- [Signal Task](#signal-task) | ||
|
||
|
||
## `Run Task` | ||
|
||
runs a command inside of a new container, using a specific image. | ||
|
||
| Property | Description | Required | | ||
|-|-|-| | ||
| [`image`](#image) | Docker image to use | Yes | | ||
| [`pull`](#pull) | Pull image before executing task | No | | ||
| [`auto_remove`](#pull) | Remove container after task is finished | No | | ||
| [`environment`](#environment) | Add environment variables | No | | ||
| [`volumes`](#volumes) | Volumes to mount into the container | No | | ||
| [`command`](#command) | Override the default image command | No | | ||
|
||
|
||
#### **image** | ||
Specify the image to start the container from. | ||
```yml | ||
image: redis | ||
image: ubuntu:18.04 | ||
image: tutum/influxdb | ||
image: example-registry.com:4000/postgresql | ||
image: a4bc65f | ||
``` | ||
#### **pull** | ||
Pull image before executing task. Default value is *missing* | ||
```yml | ||
pull: always # Always pull before executing task | ||
pull: never # Don't pull image automatically | ||
pull: missing # Pull image if not found locally | ||
``` | ||
#### **pull** | ||
Remove container after task is finished. Default value is `true` | ||
|
||
```yml | ||
auto_remove: false | ||
``` | ||
|
||
#### **environment** | ||
Add environment variables. You can use either an array or a dictionary. Any boolean values (true, false, yes, no) need to be enclosed in quotes to ensure they are not converted to True or False by the YML parser. | ||
|
||
```yml | ||
environment: | ||
RACK_ENV: development | ||
SHOW: 'true' | ||
SESSION_SECRET: | ||
environment: | ||
- RACK_ENV=development | ||
- SHOW=true | ||
- SESSION_SECRET | ||
``` | ||
|
||
#### **volumes** | ||
Bind mount host machine directory into the container. It uses `SOURCE:TARGET[:MODE]` format, where SOURCE is a host path and TARGET is the container path where the directory is mounted. Standard modes are ro for read-only and rw for read-write (default). | ||
|
||
```yml | ||
volumes: | ||
- /opt/data:/var/lib/mysql | ||
- /etc/config:/etc/config:ro | ||
``` | ||
|
||
#### **command** | ||
Override the default image command. The command can also be a list | ||
|
||
```yml | ||
command: touch /tmp/example | ||
command: ["touch", "/tmp/example"] | ||
``` | ||
|
||
## `Exec Task` | ||
|
||
Runs a new command in a running container | ||
|
||
| Property | Description | Required | | ||
|-|-|-| | ||
| [`container`](#container) | Container name or container id | Yes | | ||
| [`command`](#command) | Command to execute inside the container | Yes | | ||
|
||
|
||
#### **container** | ||
Container name or container id of the container were the command should be executed. | ||
|
||
```yml | ||
container: my_container | ||
container: c9b92d9a79d3 | ||
``` | ||
|
||
#### **command** | ||
Command to execute inside the container. The command can also be a list | ||
|
||
```yml | ||
command: touch /tmp/example | ||
command: ["touch", "/tmp/example"] | ||
``` | ||
|
||
## `Signal Task` | ||
Send a signal to the main process inside the container. Similar to `docker kill --signal` | ||
|
||
| Property | Description | Required | | ||
|-|-|-| | ||
| [`container`](#container) | Container name or container id | Yes | | ||
| [`signal`](#signal) | Signal to send to the process | Yes | | ||
|
||
#### **container** | ||
Container name or container id of the container were the signal will be sent. | ||
|
||
```yml | ||
container: my_container | ||
container: c9b92d9a79d3 | ||
``` | ||
|
||
#### **signal** | ||
Signal to send to the process. | ||
|
||
```yml | ||
signal: SIGHUP | ||
``` |
Oops, something went wrong.