From efa20ae0f0321ca36349041c6fe79116b201df14 Mon Sep 17 00:00:00 2001 From: nxshock Date: Sun, 20 Nov 2022 14:56:40 +0500 Subject: [PATCH] Move job examples to separate dir --- README.md | 40 +--------------------------- _jobExamples/advanced.conf | 23 ++++++++++++++++ _jobExamples/basic.conf | 6 +++++ _jobExamples/call_sql_procedure.conf | 7 +++++ 4 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 _jobExamples/advanced.conf create mode 100644 _jobExamples/basic.conf create mode 100644 _jobExamples/call_sql_procedure.conf diff --git a/README.md b/README.md index 6e8caf6..8b64650 100644 --- a/README.md +++ b/README.md @@ -5,45 +5,7 @@ ## Usage 1. Create `gron.d` directory -2. Create job config in `gron.d/job1.conf` ([TOML](https://en.wikipedia.org/wiki/TOML) format): - ```toml - Type = "cmd" # command execution - Category = "Test jobs" # jobs category name - Cron = "* * * * *" # cron instructions +2. Create job config in `gron.d/job1.conf` ([TOML](https://en.wikipedia.org/wiki/TOML) format). See examples in [_jobExamples](_jobExamples). - 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 - 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 - - OnSuccessCmd = "echo 'Job finished.'" # execute cmd on job success - OnErrorCmd = "echo 'Error occurred: {{.Error}}'" # execute cmd on job error - - - OnSuccessHttpGetUrl = "" - OnErrorHttpGetUrl = "http://127.0.0.1/alerts?title={{.JobName}}%20failed&message={{.Error}}&tags=warning" - - OnSuccessHttpPostUrl = "http://127.0.0.1/alerts" - OnSuccessMessageFmt = "Job {{.JobName}} finished." - - OnErrorHttpPostUrl = "http://127.0.0.1/alerts" - OnErrorMessageFmt = "Job {{.JobName}} failed:\n\n{{.Error}}" - ``` 3. Launch `gron` binary 4. HTTP interface available on http://127.0.0.1:9876 diff --git a/_jobExamples/advanced.conf b/_jobExamples/advanced.conf new file mode 100644 index 0000000..cb4719d --- /dev/null +++ b/_jobExamples/advanced.conf @@ -0,0 +1,23 @@ +Type = "cmd" # command execution +Category = "Test jobs" # jobs category name +Description = "print 'Hello' every minute" # job description +Cron = "* * * * *" # cron instructions + +Command = "echo Hello" # command to execute + +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 + +OnSuccessCmd = "echo 'Job finished.'" # execute cmd on job success +OnErrorCmd = "echo 'Error occurred: {{.Error}}'" # execute cmd on job error + +# HTTP client callbacks +OnSuccessHttpGetUrl = "http://127.0.0.1/alerts?title={{.JobName}}%20finished" +OnErrorHttpGetUrl = "http://127.0.0.1/alerts?title={{.JobName}}%20failed&message={{.Error}}&tags=warning" + +OnSuccessHttpPostUrl = "http://127.0.0.1/alerts" +OnSuccessMessageFmt = "Job {{.JobName}} finished." + +OnErrorHttpPostUrl = "http://127.0.0.1/alerts" +OnErrorMessageFmt = "Job {{.JobName}} failed:\n\n{{.Error}}" \ No newline at end of file diff --git a/_jobExamples/basic.conf b/_jobExamples/basic.conf new file mode 100644 index 0000000..6250967 --- /dev/null +++ b/_jobExamples/basic.conf @@ -0,0 +1,6 @@ +Type = "cmd" # command execution +Category = "Test jobs" # jobs category name +Description = "print 'Hello' every minute" # job description +Cron = "* * * * *" # cron instructions + +Command = "echo Hello" # command to execute diff --git a/_jobExamples/call_sql_procedure.conf b/_jobExamples/call_sql_procedure.conf new file mode 100644 index 0000000..d32ed5f --- /dev/null +++ b/_jobExamples/call_sql_procedure.conf @@ -0,0 +1,7 @@ +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