caretakerd
Version: 1.0.9
caretakerd is a simple process supervisor. There are no external dependencies and it is optimized for containerization (as used in Docker) and simple configuration.
Topics
Features
Getting started
Installing
Download your matching distribution files and extract it where you like.
Linux 64-Bit example:
## Download directly from GitHub...
sudo curl -SL https://github.com/echocat/caretakerd/releases/download/v1.0.9/caretakerd-linux-amd64.tar.gz \
| tar -xz --exclude caretakerd.html -C /usr/bin
## Download from caretakerd.echocat.org...
sudo curl -SL https://caretakerd.echocat.org/v1.0.9/download/caretakerd-linux-amd64.tar.gz \
| tar -xz --exclude caretakerd.html -C /usr/bin
## Download the latest version from caretakerd.echocat.org...
sudo curl -SL https://caretakerd.echocat.org/latest/download/caretakerd-linux-amd64.tar.gz \
| tar -xz --exclude caretakerd.html -C /usr/bin
Hint: You can use this command in a Dockerfile
to create caretakerd in a docker container.
See Downloads for all possible download locations.
Configuring
Place your configuration file at your favorite location. Default location is:
- Linux:
/etc/caretakerd.yaml
- Mac OS X:
/etc/caretakerd.yaml
- Windows:
C:\ProgramData\caretakerd\config.yaml
See Configuration examples for a quick start or consult the Configuration structure for all possibilities.
Run
caretakerd run
Control caretakerd with caretakerctl
Precondition: RPC is enabled. See RPC enabled configuration example on how to do this.
## Start a service that is not already running
$ caretakerctl start peasant
## Retrieve the status of a service
$ caretakerctl status peasant
## Stop an already running service
$ caretakerctl stop peasant
See in action with Docker
You can find lots of working demos on github.com/echocat/caretakerd-docker-demos. Try it out!
Downloads
Commands
The way how the binary reacts depends on its command/file name. A simple rename or symlink will change the behavior of the binary.
Pattern
| Target command
| Examples
|
*/caretakerd*
| caretakerd
| /usr/bin/caretakerd
/usr/bin/caretakerd-linux-amd64
C:\Program Files\caretakerd\caretakerd-windows-amd64.exe
|
*/caretakerctl*
| caretakerctl
| /usr/bin/caretakerctl
/usr/bin/caretakerctl-linux-amd64
C:\Program Files\caretakerd\caretakerctl-windows-amd64.exe
|
Everything else that does not matches one of above.
| caretaker
| /usr/bin/caretaker
/usr/bin/caretaker-linux-amd64
C:\Program Files\caretakerd\caretaker-windows-amd64.exe
|
caretakerd
usage: caretakerd [<flags>] <command> [<args> ...]
Simple control daemon for processes.
Flags:
-c, --config=/etc/caretakerd.yaml
Configuration file for daemon. ($CTD_CONFIG)
-a, --address=tcp://localhost:57955
Listen address of the daemon.
Commands:
help [<command>...]
Show help.
version
Print the actual version and other useful information.
run [<args>...]
Run caretakerd in foreground.
caretakerctl
usage: caretakerctl [<flags>] <command> [<args> ...]
Remote control for caretakerd
Flags:
-c, --config=/etc/caretakerd.yaml
Configuration file for control. ($CTCTL_CONFIG)
-a, --address=tcp://localhost:57955
Listen address of the daemon.
-p, --pem=/var/run/caretakerd.key
Location of PEM file which contains the private public key pair for access
to the daemon.
Commands:
help [<command>...]
Show help.
version
Print the actual version and other useful information.
config <target>
Returns configurations for defined service, '!daemon' or '!control'.
get [<target>]
Query states for given service or if nothing specified for all services.
status <service>
Query status of a service.
pid <service>
Query pid of a service.
start <service>
Starts a service.
restart <service>
Restarts a service.
stop <service>
Stops a service.
kill <service>
Kills a service.
signal <service> <signal>
Send a signal to service.
caretaker
usage: caretaker [<flags>] <command> [<args> ...]
Simple control daemon for processes including remote control for itself.
Flags:
-c, --config=/etc/caretakerd.yaml
Configuration file for daemon and control. ($CT_CONFIG)
-a, --address=tcp://localhost:57955
Listen address of the daemon.
-p, --pem=/var/run/caretakerd.key
Location of PEM file which contains the private public key pair for access
to the daemon.
Commands:
help [<command>...]
Show help.
version
Print the actual version and other useful information.
daemon [<args>...]
Run caretakerd in foreground.
config <target>
Returns configurations for defined service, '!daemon' or '!control'.
get [<target>]
Query states for given service or if nothing specified for all services.
status <service>
Query status of a service.
pid <service>
Query pid of a service.
start <service>
Starts a service.
restart <service>
Restarts a service.
stop <service>
Stops a service.
kill <service>
Kills a service.
signal <service> <signal>
Send a signal to service.
Configuration
Examples
RPC enabled
# Run the service king at startup and enable rpc.
# peasant will only be started of "caretakerctl start peasant" is called.
# king will run for 120 seconds. If king is finished the whole careteakerd
# will go down.
rpc:
enabled: true
services:
king:
type: master
command: ["sleep", "120"]
peasant:
type: onDemand
command: ["sleep","10"]
Simple
# Run the service king, queen and wonderland at startup.
# king will run for 120 seconds. If king is finished the whole careteakerd will
# go down and also terminate queen.
# wonderland will only be print "Follow the white rabbit." to console and exit
# immediately.
services:
king:
type: master
command: ["sleep","120"]
queen:
command: ["sleep", "240"]
wonderland:
command: ["echo", "Follow the white rabbit."]
With cron expression
# Run the service king and queen at startup.
# queen will run every 5th second until king is finished.
# king will run for 120 seconds. If king is finished the whole careteakerd will
# go down.
services:
king:
type: master
command: ["sleep","120"]
queen:
command: ["echo","Hello world from the queen!"]
cronExpression: "0,5,10,15,20,25,30,35,40,45,50,55 * * * * *"
Structure
# (keyStore.KeyStore) Defines how the encryption of caretakerd works.
keyStore:
# (keyStore.Type) Defines the type of the instance keyStore.
type: generated
# (string) Defines the pemFile which contains the key and certificate to be used.
pemFile: ""
# (string) Defines some hints, for example to store in the format [<key:`value`>...].
hints: "algorithm:`rsa` bits:`1024`"
# (string) File where trusted certificates are stored in.
caFile: ""
# (rpc.Rpc) Defines how caretaker can controlled remotely.
rpc:
# (bool) If this is set to true it is possible to control caretakerd remotely.
enabled: false
# (values.SocketAddress) Address where caretakerd RPC interface is listened to.
listen: "tcp://localhost:57955"
# (control.Control) Defines the access rights of caretakerctl to caretakerd.
control:
# (access.Access) Configures the permission of caretakerctl to control caretakerd remotely and how to obtain the credentials for it.
access:
# (access.Type) Defines how this access will be ensured.
type: "generateToFile" (for control/caretakerctl) "none" (for services)
# (access.Permission) Defines what the control/service can do with caretakerd.
permission: "readWrite" (for control/caretakerctl) "forbidden" (for services)
# (string) If the property type = trusted, the certificates specified in this file are used to trust remote connections.
pemFile: ""
# (uint32) Permission in filesystem of the generated pem file.
pemFilePermission: 0600
# (string) If set, this user owns the generated pem file.
pemFileUser: ""
# (logger.Logger) Configures the logger for caretakerd itself.
logger:
# (logger.Level) Minimal log level the logger uses to log error messages.
level: info
# (logger.Level) If the service prints something to stdout, the instance will be logged with the corresponding instance level.
stdoutLevel: info
# (logger.Level) If the service prints something to stderr, the instance will be logged with the corresponding instance level.
stderrLevel: error
# (string) Target file of the logger.
filename: "console"
# (int) Maximum size in megabytes of the log file before it gets rotated.
maxSizeInMb: 500
# (int) Maximum number of old log files to retain.
maxBackups: 500
# (int) Maximum number of days to retain old log files based on the timestamp encoded in their filename.
maxAgeInDays: 1
# (logger.Pattern) Pattern how to format the log messages to output with.
pattern: "%d{YYYY-MM-DD HH:mm:ss} [%-5.5p] [%c] %m%n%P{%m}"
# ([string]service.Service) Services configuration to run with caretakerd.
services:
<service name>:
# (service.Type) Defines how this service will be run by caretakerd.
type: autoStart
# ([]string) The command the service process has to start with.
command: []
# ([][]string) Commands to be executed before execution of the actual command.
preCommands: []
# ([][]string) Commands to be executed after execution of the actual command.
postCommands: []
# (service.CronExpression) If configured this will trigger the service at this specific times.
cronExpression: ""
# (int) Wait before the service process will start the first time.
startDelayInSeconds: 0
# ([]int) Every of these values represents an expected success exit code.
successExitCodes: [0]
# (int) Signal which will be send to the service when a stop is requested.
stopSignal: "TERM"
# (values.SignalTarget) Defines who have to receive the stop signal.
stopSignalTarget: "processGroup"
# ([]string) Command to be executed to stop the service.
stopCommand: []
# (int) Timeout to wait before killing the service process after a stop is requested.
stopWaitInSeconds: 30
# (string) User under which the service process will be started.
user: ""
# ([string]string) Environment variables to pass to the process.
environment: []
<environment name>:
# (bool) Additionally pass the environment variables started with caretakerd to the service process.
inheritEnvironment: true
# (string) Working directory to start the service process in.
directory: ""
# (values.RestartType) Configure how caretakerd will handle the end of a process.
autoRestart: onFailures
# (int) Seconds to wait before restart of a process.
restartDelayInSeconds: 5
# (access.Access) Configures the permission of this service to control caretakerd remotely and how to obtain the credentials for it.
access:
# (access.Type) Defines how this access will be ensured.
type: "generateToFile" (for control/caretakerctl) "none" (for services)
# (access.Permission) Defines what the control/service can do with caretakerd.
permission: "readWrite" (for control/caretakerctl) "forbidden" (for services)
# (string) If the property type = trusted, the certificates specified in this file are used to trust remote connections.
pemFile: ""
# (uint32) Permission in filesystem of the generated pem file.
pemFilePermission: 0600
# (string) If set, this user owns the generated pem file.
pemFileUser: ""
# (logger.Logger) Configures the logger for this specific service.
logger:
# (logger.Level) Minimal log level the logger uses to log error messages.
level: info
# (logger.Level) If the service prints something to stdout, the instance will be logged with the corresponding instance level.
stdoutLevel: info
# (logger.Level) If the service prints something to stderr, the instance will be logged with the corresponding instance level.
stderrLevel: error
# (string) Target file of the logger.
filename: "console"
# (int) Maximum size in megabytes of the log file before it gets rotated.
maxSizeInMb: 500
# (int) Maximum number of old log files to retain.
maxBackups: 500
# (int) Maximum number of days to retain old log files based on the timestamp encoded in their filename.
maxAgeInDays: 1
# (logger.Pattern) Pattern how to format the log messages to output with.
pattern: "%d{YYYY-MM-DD HH:mm:ss} [%-5.5p] [%c] %m%n%P{%m}"
# (string) Contains the source where this config comes from.
-:
Environment mapping
There are several environment variables mapped to configuration parameters. These environment variables are overwriting values from configuration files.
Hint: Every caretakerd environment variable starts with CTD
= CareTakerD
Examples
caretakerd.yaml
services:
king:
type: master
command: ["echo", "Hello world!"]
user: king
Executions
$ caretakerd run
Hello world!
$ export CTD.king.COMMAND=whoami
$ caretakerd run
king
$ export CTD.king.USER=root
$ caretakerd run
root
Services
Global
Data Types
Caretakerd
object
Root configuration of caretakerd.
Properties
-
Defines how the encryption of caretakerd works.
This is especially important if RPC
is used.
For details see keyStore.KeyStore
.
-
Defines how caretaker can controlled remotely.
For details see rpc.Rpc
.
-
Defines the access rights of caretakerctl to caretakerd.
This requires RPC
enabled.
For details see control.Control
.
-
Configures the logger for caretakerd itself.
This does not include output of services.
For details see logger.Logger
.
-
Services configuration to run with caretakerd.
Important: This is a map and requires exact one service
configured as type
= master
.
For details see service.Service
.
-
-
string
Contains the source where this config comes from.
access.Access
object
Config to access caretakerd.
Properties
-
type
access.Type
="generateToFile" (for control/caretakerctl) "none" (for services)
Defines how this access will be ensured.
For details see possible values access.Type
.
-
permission
access.Permission
="readWrite" (for control/caretakerctl) "forbidden" (for services)
Defines what the control/service can do with caretakerd.
For details see possible values access.Permission
.
-
pemFile
string
=""
If the property type
= trusted
,
the certificates specified in this file are used to trust remote connections. Not matching remote connections will be
rejected.
If the property type
= generateToFile
,
caretakerd generates this file that must be used by remote connections.
Important: If the property type
= generateToFile
,
this property is required.
-
pemFilePermission
uint32
=0600
Permission in filesystem of the generated pem file
.
-
pemFileUser
string
=""
If set, this user owns the generated pem file
.
Otherwise it is owned by the user caretakerd is running with.
access.Permission
enum
Permission represents the service’s/node’s permissions in caretakerd.
Elements
-
forbidden
The remote control/service does not have any permissions in caretakerd.
-
readOnly
The remote control/service does only have read permissions in caretakerd.
-
readWrite
The remote control/service does have read and write permissions in caretakerd.
access.Type
enum
Elements
-
none
-
trusted
-
generateToEnvironment
Generates a new certificate to the environment variable CTD_PEM
and trusts it.
-
generateToFile
control.Control
object
Description
Defines the access rights of caretakerctl to caretakerd.
Properties
-
Configures the permission of caretakerctl to control caretakerd remotely
and how to obtain the credentials for it.
For details see access.Access
.
keyStore.KeyStore
object
Description
Defines the keyStore of caretakerd.
Properties
-
Defines the type of the instance keyStore.
-
pemFile
string
=""
Defines the pemFile which contains the key and certificate to be used.
This has to be of type PEM and has to contain the certificate and private key.
Currently only private keys of type RSA are supported.
This property is only evaluated and required if type
is set to
fromFile
.
-
hints
string
="algorithm:`rsa` bits:`1024`"
Defines some hints, for example to store in the format [<key:`value`>...]
.
Possible hints are:
algorithm
: Algorithm to be used to create new keys. Currently only rsa
is supported.
bits
: Number of bits to create a new key with.
-
caFile
string
=""
File where trusted certificates are stored in. This has to be in PEM format.
keyStore.Type
enum
Description
Represents the type of the keyStore.
Elements
-
generated
Indicates that caretakerd have to generate its own keyStore on startup.
This is the best solution in most cases.
-
fromFile
Load keyStore from a provided PEM file.
If this instance type is selected, the instance file have to be provided.
-
fromEnvironment
Load the KeyStore from the environment variable CTD_PEM
in PEM format.
If this instance type is selected, the instance variable have to be provided.
logger.Logger
object
Description
A logger handles every output generated by the daemon itself, the process or other parts controlled by the daemon.
Properties
-
Minimal log level the logger uses to log error messages. All levels below are ignored.
-
If the service prints something to stdout
, the instance will be logged with the corresponding instance level.
-
If the service prints something to stderr
, the instance will be logged with the corresponding instance level.
-
filename
string
="console"
Target file of the logger. The file will be created if it does not exist - but not the parent directory.
If the instance value is set to console
, the whole output will go to stdout
or to stderr
on every log level
above or equal to warning
.
-
maxSizeInMb
int
=500
Maximum size in megabytes of the log file before it gets rotated.
This is ignored if filename
is set to console
.
-
maxBackups
int
=500
Maximum number of old log files to retain.
This is ignored if filename
is set to console
.
-
maxAgeInDays
int
=1
Maximum number of days to retain old log files based on the
timestamp encoded in their filename. Note that a day is defined as 24
hours and may not exactly correspond to calendar days due to daylight
savings, leap seconds etc.
This is ignored if filename
is set to console
.
-
pattern
logger.Pattern
="%d{YYYY-MM-DD HH:mm:ss} [%-5.5p] [%c] %m%n%P{%m}"
Pattern how to format the log messages to output with.
logger.Level
enum
Description
Represents a level for logging with a Logger
Elements
-
debug
Used for debugging purposes. This level is only required if something goes wrong and you need more information.
-
info
This is the regular level. Every normal message will be logged with instance level.
-
warning
If a problem appears but the program is still able to continue its work, this instance level is used.
-
error
If a problem appears and the program is not longer able to continue its work, this instance level is used.
-
fatal
This level is used on fatal problems.
logger.Pattern
string
Description
A flexible pattern string.
The conversion pattern is closely related to the conversion pattern of the printf function in C. A conversion pattern is composed
of literal text and format control expressions called conversion specifiers.
You are free to insert any literal text within the conversion pattern.
Each conversion specifier starts with a percent sign (%
) and is followed by optional format modifiers and a conversion character. The conversion character specifies the
type of data, e.g. category, priority, date, thread name. The format modifiers control such things as field width, padding, left and right justification.
The following is a simple example.
If the conversion pattern is “%d{YYYY-MM-DD HH:mm:ss} [%-5p]: %m%n” and the log4j environment has been set to use a PatternLayout. Then the statement will be:
LOG debug Message 1
LOG warn Message 2
and would yield the output
2016-01-09 14:59:30 [DEBUG] Message 1
2016-01-09 14:59:31 [WARN ] Message 2
Note that there is no explicit separator between text and conversion specifiers. The pattern parser knows when it has reached the end of a conversion specifier when it reads
a conversion character. In the example above the conversion specifier %-5p means the priority of the logging event should be left justified to a width of five characters.
The recognized conversion characters are
Conversion patterns
%d[{<dateFormat>}]
: Prints out the log’s creation date. Possible patterns are:
- Month
M
: 1 2 … 12
MM
: 01 01 … 12
Mo
: 1st 2nd … 12th
MMM
: Jan Feb … Dec
MMMM
: January February … December
- Day of Month
D
: 1 2 … 31
DD
: 01 02 … 31
Do
: 1st 2nd … 31st
- Day of Week
ddd
: Sun Mon … Sat
dddd
: Sunday Monday … Saturday
- Year
YY
: 70 71 … 12
YYYY
: 1970 1971 … 2012
- Hour
H
: 0 1 2 … 23
HH
: 00 01 02 .. 23
h
: 1 2 … 12
hh
: 01 02 … 12
- Minute
m
: 0 1 2 … 59
mm
: 00 01 02 … 59
- Second
s
: 0 1 2 … 59
ss
: 00 01 02 … 59
- AM / PM
- Timezone
Z
: -07:00 -06:00 … +07:00
ZZ
: -0700 -0600 … +0700
%m
: The log message.
%c[{<maximumNumberOfElements>}]
: Holds the logging category. Normally the instance is the name of the logger or the service. If you do not specify maximumNumberOfElements
the full name is displayed. For example, if the instance is %c{2}
and the name of the category is a.b.c
then the output result is b.c
.
%F[{<maximumNumberOfPathElements>}]
: Holds the source file that logs the instance event. If you do not specify maximumNumberOfPathElements
the full file name is displayed. For example, if the instance is %F{2}
and the file name is /a/b/c.go
then the output result is b/c.go
.
%l
: Holds the source location of the log event.
%L
: Holds the line number where the log event was created.
%C[{<maximumNumberOfElements>}]
: Holds the source code package. If you do not specify maximumNumberOfElements
the full name is displayed. For example, if the instance is %C{2}
and the name of the package is a.b.c
then the output result is b.c
.
%M
: Holds the method name where the log event was created.
%p
: Holds the priority or better called log level.
%P[{<subFormatPattern>}]
: Stacktrace of the location where a problem was raised that caused the instance log message.
%r
: Uptime of the logger.
%n
: Prints out a new line character.
%%
: Prints out a %
character.
rpc.Rpc
object
Description
Defines the remote access to caretakerd.
Properties
-
enabled
bool
=false
If this is set to true
it is possible to control caretakerd remotely.
This includes the caretakerctl
command and also
by the services itself.
Hint: This does NOT automatically grants each of it caretakerd access rights.
This is separately handled by the following access properties:
-
Address where caretakerd RPC interface is listened to.
For details of possible values see values.SocketAddress
.
service.Service
object
Represents the configuration of a service in caretakerd.
Properties
-
Defines how this service will be run by caretakerd.
For details of possible values see values.RestartType
.
Important: Exactly one of the services have to be configured as
master
.
-
command
[]string
=[]
The command the service process has to start with. The called command has to be run in the foreground - or in other words: Should not daemonize.
Hint: If there is no command line provided, this service cannot be started and caretakerd will
fail.
PATH expansion
The provided commands are resolved from the PATH
environment provided to caretakerd.
This makes it possible to use the names of the binaries like sleep
instead of /usr/bin/sleep
.
Parameter evaluation
Environment variables could be included like:
command: ["echo", "${MESSAGE}"]
environment:
MESSAGE: "Hello world!"
$ caretakerd run
Hello world!
Special master handling
If the service is configured as type
= master
every parameter which was passed to caretakerd itself will be enriched to the called command line of the service process.
Config example:
command: ["echo", "Hello"]
Run examples:
$ caretakerd run
Hello
$ caretakerd run "world!"
Hello world!
-
preCommands
[][]string
=[]
Commands to be executed before execution of the actual command
.
If one of these commands fails, the whole service will also marked as failed. The actual
command
will not be invoked and the autoRestart
handling will be initiated.
Only exit codes of value 0
will be accepted as success.
If there is a minus (-
) provided as first item of the command, every error of this command will be ignored.
Example:
preCommands:
- ["-", "program.sh", "prepare"] # Ignore if fails
- ["program.sh", "prepareAndDoNotFail"] # Do not ignore if fails
command: ["program.sh", "run"]
-
postCommands
[][]string
=[]
Commands to be executed after execution of the actual command
.
Every result of these commands are ignored and will not force another behaviour - Exception: an error is logged.
Only exit codes of value 0
will be accepted as success.
If there is a minus (-
) provided as first item of the command, every error of this command will be ignored.
Example:
command: ["program.sh", "run"]
postCommands:
- ["-", "program.sh", "cleanUp"] # Ignore if fails
- ["program.sh", "cleanUpAndDoNotFail"] # Log if fails
-
If configured this will trigger the service at this specific times. If not the service will
run as a normal process just once (except of the autoRestart
handling).
For details of possible values see service.CronExpression
.
-
startDelayInSeconds
int
=0
Wait before the service process will start the first time.
Hint: Every run triggered by cronExpression
will also wait for this delay.
-
successExitCodes
[]int
=[0]
Every of these values represents an expected success exit code.
If a service ends with one of these values, the service will not be restarted.
Other values will trigger a auto restart if configured.
See: autoRestart
-
stopSignal
int
="TERM"
Signal which will be send to the service when a stop is requested.
You can use the signal number here and also names like "TERM"
or "KILL"
.
-
Defines who have to receive the stop signal.
Hint: If the service have to be killed, always processGroup
is used.
-
stopCommand
[]string
=[]
Command to be executed to stop the service.
From the moment on this command is called, the stopWaitInSeconds
are running.
It is not important when this stopCommand ends or what is the exit code.
If this command is executed and the service does not end within the configured stopWaitInSeconds
,
the service will be killed.
Only exit codes of value 0
will be accepted as success. Other codes are logged as error.
If there is a minus (-
) provided as first item of the command, every error of this command will be ignored.
Hint: If this property is configured, stopSignal
will not be evaluated.
-
stopWaitInSeconds
int
=30
Timeout to wait before killing the service process after a stop is requested.
-
user
string
=""
User under which the service process will be started.
-
environment
[string]string
=[]
Environment variables to pass to the process.
-
inheritEnvironment
bool
=true
Additionally pass the environment variables started with caretakerd to the service process.
-
directory
string
=""
Working directory to start the service process in.
-
-
restartDelayInSeconds
int
=5
Seconds to wait before restart of a process.
If a process should be restarted (because of autoRestart
), caretakerd will wait this seconds before restart is initiated.
-
Configures the permission of this service to control caretakerd remotely
and how to obtain the credentials for it.
For details see access.Access
.
-
Configures the logger for this specific service.
For details see logger.Logger
.
service.CronExpression
string
Description
A cron expression represents a set of times, using 6 space-separated fields.
Field name
| Mandatory
| Allowed values
| Allowed special characters
|
Seconds
| No
| 0-59
| * / , -
|
Minutes
| Yes
| 0-59
| * / , -
|
Hours
| Yes
| 0-23
| * / , -
|
Day of month
| Yes
| 1-31
| * / , - ?
|
Month
| Yes
| 1-12 or JAN-DEC
| * / , -
|
Day of week
| Yes
| 0-6 or SUN-SAT
| * / , - ?
|
Note: Month and Day-of-week field values are case insensitive. SUN
, Sun
, and sun
are equally accepted.
Special Characters
- Asterisk (
*
)
The asterisk indicates that the cron expression will match all values of the field; e.g., using an asterisk in the
5th field (month) would match every month.
- Slash (
/
)
Slashes are used to describe increments of ranges. For example 3-59/15
in the 1st field (minutes) would match the
3rd minute of the hour and every 15 minutes thereafter. The form *\/...
is equivalent to the form first-last/...
, that is, an increment
over the largest possible range of the field. The form N/...
is accepted as meaning N-MAX/...
, that is, starting at N, use the increment
until the end of that specific range. It does not wrap around.
- Comma (
,
)
Commas are used to separate items of a list. For example, using MON,WED,FRI
in the 5th field (day of week) would match Mondays,
Wednesdays and Fridays.
- Hyphen (
-
)
Hyphens are used to define ranges. For example, 9-17
would match every hour between 9am and 5pm (inclusive).
- Question mark (
?
)
Question marks may be used instead of *
for leaving either day-of-month or day-of-week blank.
Predefined schedules
You may use one of several pre-defined schedules in place of a cron expression.
Entry
| Description
| Equivalent To
|
@yearly (or @annually)
| Run once a year, midnight, Jan. 1st
| 0 0 0 1 1 *
|
@monthly
| Run once a month, midnight, first of month
| 0 0 0 1 * *
|
@weekly
| Run once a week, midnight on Sunday
| 0 0 0 * * 0
|
@daily (or @midnight)
| Run once a day, midnight
| 0 0 0 * * *
|
@hourly
| Run once an hour, beginning of hour
| 0 0 * * * *
|
Intervals
You may also schedule a job to be executed at fixed intervals. This is supported by formatting the cron spec as follows:
@every <duration>
where duration
is a string accepted by time.ParseDuration.
For example, @every 1h30m10s
would indicate a schedule that activates every 1 hour, 30 minutes, 10 seconds.
Hint: The interval does not take the job runtime into account. For example, if a job takes 3 minutes to run and it
is scheduled to run every 5 minutes, it will have only 2 minutes of idle time between each run.
service.Type
enum
Description
Identifies the different ways caretakerd handles services.
Elements
-
onDemand
The service is not automatically started by caretakerd.
You have to use caretakerctl
or execute an RPC call from another service
to start it.
This service will be automatically stopped if the master
was also stopped.
-
autoStart
This services is automatically started by caretakerd.
This service will be automatically stopped if the master
was also stopped.
-
master
This service is automatically started by caretakerd and influences all other services.
Important: One of all available services must be specified as master
.
Every other service lives and dies together with the master
.
values.RestartType
enum
Description
RestartType tells caretakerd what to do if a process ends.
Elements
-
never
Never restart the process.
-
onFailures
Only restart the process on failures.
-
always
Always restart the process. This means on success and on failures.
values.SignalTarget
enum
SignalTarget defines who have to receives a signal.
Elements
-
process
Send a signal to the process only.
-
processGroup
Send a signal to the whole process group.
-
mixed
Send every signal only to a process - except KILL and STOP. This are send to the processGroup.
values.SocketAddress
string
Description
SocketAddress represents a socket address in the format “://“.
Protocols
- “tcp“ This address connects or binds to a TCP socket. The “target“ should be of format “:“.
Examples:
- “tcp://localhost:57955“: Listen on IPv4 and IPv6 local addresses
- “tcp://[::1]:57955“: Listen on IPv6 local address
- “tcp://0.0.0.0:57955“: Listen on all addresses - this includes IPv4 and IPv6
- “tcp://192.168.0.1:57955“: Listen on specific IPv4 address
- “unix“ This address connects or binds to a UNIX file socket. The “target“ should be the location of the socket file.
Example:
- “unix:///var/run/caretakerd.sock“
Support
If you need support, you can file a ticket at our issue tracker
or join our chat at gitter.im/echocat/caretakerd.
Contributing
caretakerd is an open source project of echocat.
If you want to make this project even better, you can contribute to this project on Github
by fork us.
License
caretakerd
The MIT License (MIT)
Copyright (c) echocat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.