2022-03-27 12:39:24 +05:00
|
|
|
# gron
|
2022-03-26 13:23:39 +05:00
|
|
|
|
2022-03-29 21:38:04 +05:00
|
|
|
*SystemD and cron inspired job scheduler*
|
2022-03-26 13:23:39 +05:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2022-03-27 21:20:17 +05:00
|
|
|
1. Create `gron.d` directory
|
2022-03-30 18:26:52 +05:00
|
|
|
2. Create job config in `gron.d/job1.conf` ([TOML](https://en.wikipedia.org/wiki/TOML) format):
|
2022-03-26 13:23:39 +05:00
|
|
|
```toml
|
2022-05-10 19:44:41 +05:00
|
|
|
Type = "cmd" # command execution
|
|
|
|
Cron = "* * * * *" # cron instructions
|
|
|
|
|
|
|
|
Command = "echo Hello" # command to execute
|
|
|
|
```
|
|
|
|
|
|
|
|
SQL job:
|
|
|
|
```toml
|
|
|
|
Type = "sql" # sql execution
|
|
|
|
Cron = "* * * * *" # cron instructions
|
|
|
|
Description = "execute procedure every minute" # job description
|
|
|
|
|
|
|
|
Driver = "pgx" # "pgx" for Postgresql, "oracle" for Oracle, "sqlserver" for Microsoft SQL Server
|
|
|
|
ConnectionString = "postgres://login:password@host:port/database?sslmode=disable" # each driver has different syntax
|
|
|
|
SqlText = "CALL procedure" # command to execute
|
|
|
|
```
|
|
|
|
|
|
|
|
Add other options if needed:
|
|
|
|
```toml
|
2022-03-29 21:44:16 +05:00
|
|
|
Description = "print Hello every minute" # job description
|
|
|
|
NumberOfRestartAttemts = 3 # number of restart attemts
|
|
|
|
RestartSec = 5 # the time to sleep before restarting a job (seconds)
|
|
|
|
RestartRule = "on-error" # Configures whether the job shall be restarted when the job process exits
|
2022-03-26 13:23:39 +05:00
|
|
|
```
|
2022-03-27 12:43:57 +05:00
|
|
|
3. Launch `gron` binary
|
2022-03-26 13:25:47 +05:00
|
|
|
4. HTTP interface available on http://127.0.0.1:9876
|