-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
74 changed files
with
17,175 additions
and
69 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
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 |
---|---|---|
|
@@ -28,17 +28,32 @@ Simple wrapper to log and handle cron errors. | |
|
||
Example: | ||
|
||
``` | ||
```sh | ||
cronguard -name cron.example "command" | ||
``` | ||
|
||
The command is executed with `bash -c`. You can use bash features like pipes. | ||
|
||
**Note**: Bash is required. | ||
|
||
### Sentry Support | ||
|
||
To enable sentry you can either create a `/etc/cronguard.yaml`, create `./cronguard.yaml` or use the environment | ||
variable `CRONGUARD_SENTRY_DSN`. | ||
|
||
If one of these is set cronguard will try to send events to sentry. If thats not possible it will fallback to default | ||
behavior. | ||
|
||
Config Example: | ||
|
||
```yaml | ||
sentry_dsn: https://[email protected]/2 | ||
``` | ||
### Quiet-Times | ||
Using `-quiet-times` one can setup time ranges during which errors are ignored. Useful to disable error handling, for example, if there is a database backup running. | ||
Using `-quiet-times` one can setup time ranges during which errors are ignored. Useful to disable error handling, | ||
for example, if there is a database backup running. | ||
|
||
Example: | ||
|
||
|
@@ -55,6 +70,6 @@ Golang time duration documentation: https://golang.org/pkg/time/#ParseDuration | |
|
||
Via go: | ||
|
||
``` | ||
```sh | ||
go get -u github.com/bitsbeats/cronguard | ||
``` |
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,39 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type ( | ||
// Config holds the optional and global configuration | ||
Config struct { | ||
SentryDSN string `yaml:"sentry_dsn"` | ||
} | ||
) | ||
|
||
// ParseConfig loads the Configfile if there is one or uses defaults | ||
func ParseConfig() *Config { | ||
c := Config{} | ||
file, err := open("cronguard.yml", "cronguard.yaml", "/etc/cronguard.yml", "/etc/cronguard.yaml") | ||
if err != nil { | ||
return &c | ||
} | ||
_ = yaml.NewDecoder(file).Decode(&c) | ||
return &c | ||
} | ||
|
||
func open(files ...string) (*os.File, error) { | ||
err := error(nil) | ||
for _, file := range files { | ||
file, err := os.Open(file) | ||
if err == nil { | ||
return file, nil | ||
} | ||
if !os.IsNotExist(err) { | ||
return nil, err | ||
} | ||
} | ||
return nil, err | ||
} |
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
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
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
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
Oops, something went wrong.