caretakerd

Version: 0.1.1

caretakerd is a minimal process supervisor build for easy use with no dependencies.;

Topics

Getting started

TODO!

Downloads

Commands

caretaker

NAME:
caretaker - Simple control daemon for processes including remote control for itself.

USAGE:
caretaker [global options] command ...

COMMANDS:
daemon Run caretakerd in forground.
config Query whole daemon configuration.
controlConfig Query control configuration.
services Query whole daemon configuration with all its actual service stats.
service Query service configuration and its actual stats.
serviceConfig Query service configuration.
serviceStatus, status Query service status.
servicePid, pid Query service pid.
serviceStart, start Start a service.
serviceRestart, restart Restart a service.
serviceStop, stop Stop a service.
serviceKill, kill Kill a service.
serviceSignal, signal Send a signal to service.

GLOBAL OPTIONS:
--config,c "/etc/caretakerd.yaml" Configuration file for daemon and control. [$CT_CONFIG]
--address,a "tcp://localhost:57955" Listen address of the daemon.
--pem,p "/var/run/caretakerd.key" Location of PEM file which contains the private public key pair for access to the daemon.

daemon

NAME:
   daemon - Run caretakerd in forground.

USAGE:
   daemon [<args pass to master service>...]

config

NAME:
   config - Query whole daemon configuration.

USAGE:
   config  

controlConfig

NAME:
   controlConfig - Query control configuration.

USAGE:
   controlConfig  

services

NAME:
   services - Query whole daemon configuration with all its actual service stats.

USAGE:
   services  

service

NAME:
   service - Query service configuration and its actual stats.

USAGE:
   service <service name>

serviceConfig

NAME:
   serviceConfig - Query service configuration.

USAGE:
   serviceConfig <service name>

serviceStatus

NAME:
   serviceStatus - Query service status.

USAGE:
   serviceStatus <service name>

servicePid

NAME:
   servicePid - Query service pid.

USAGE:
   servicePid <service name>

serviceStart

NAME:
   serviceStart - Start a service.

USAGE:
   serviceStart <service name>

serviceRestart

NAME:
   serviceRestart - Restart a service.

USAGE:
   serviceRestart <service name>

serviceStop

NAME:
   serviceStop - Stop a service.

USAGE:
   serviceStop <service name>

serviceKill

NAME:
   serviceKill - Kill a service.

USAGE:
   serviceKill <service name>

serviceSignal

NAME:
   serviceSignal - Send a signal to service.

USAGE:
   serviceSignal <service name> <signal>

caretakerd

NAME:
caretakerd - Simple control daemon for processes.

USAGE:
caretakerd [global options] command ...

COMMANDS:
run Run caretakerd in forground.

GLOBAL OPTIONS:
--config,c "/etc/caretakerd.yaml" Configuration file for daemon. [$CTD_CONFIG]
--address,a "tcp://localhost:57955" Listen address of the daemon.

run

NAME:
   run - Run caretakerd in forground.

USAGE:
   run [<args pass to master service>...]

caretakerctl

NAME:
caretakerctl - Remote control for caretakerd

USAGE:
caretakerctl [global options] command ...

COMMANDS:
config Query whole daemon configuration.
controlConfig Query control configuration.
services Query whole daemon configuration with all its actual service stats.
service Query service configuration and its actual stats.
serviceConfig Query service configuration.
serviceStatus, status Query service status.
servicePid, pid Query service pid.
serviceStart, start Start a service.
serviceRestart, restart Restart a service.
serviceStop, stop Stop a service.
serviceKill, kill Kill a service.
serviceSignal, signal Send a signal to service.

GLOBAL OPTIONS:
--config,c "/etc/caretakerd.yaml" Configuration file for control. [$CTCTL_CONFIG]
--address,a "tcp://localhost:57955" Listen address of the daemon.
--pem,p "/var/run/caretakerd.key" Location of PEM file which contains the private public key pair for access to the daemon.

config

NAME:
   config - Query whole daemon configuration.

USAGE:
   config  

controlConfig

NAME:
   controlConfig - Query control configuration.

USAGE:
   controlConfig  

services

NAME:
   services - Query whole daemon configuration with all its actual service stats.

USAGE:
   services  

service

NAME:
   service - Query service configuration and its actual stats.

USAGE:
   service <service name>

serviceConfig

NAME:
   serviceConfig - Query service configuration.

USAGE:
   serviceConfig <service name>

serviceStatus

NAME:
   serviceStatus - Query service status.

USAGE:
   serviceStatus <service name>

servicePid

NAME:
   servicePid - Query service pid.

USAGE:
   servicePid <service name>

serviceStart

NAME:
   serviceStart - Start a service.

USAGE:
   serviceStart <service name>

serviceRestart

NAME:
   serviceRestart - Restart a service.

USAGE:
   serviceRestart <service name>

serviceStop

NAME:
   serviceStop - Stop a service.

USAGE:
   serviceStop <service name>

serviceKill

NAME:
   serviceKill - Kill a service.

USAGE:
   serviceKill <service name>

serviceSignal

NAME:
   serviceSignal - Send a signal to service.

USAGE:
   serviceSignal <service name> <signal>

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
# imidately.

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) This is a comment for keyStore
keyStore:
# (keyStore.Type) Defines the type of instance keyStore.
type: generated
# (string) Defines the pemFile which contains the key and certificate to use.
pemFile: ""
# (string) Defines some hints for instance store in format [<key:`value`>...].
hints: "algorithm:`rsa` bits:`1024`"
# (string) File where trusted certificates are stored in.
caFile: ""
# (rpc.Rpc) 
rpc:
# (bool) 
enabled:
# (values.SocketAddress) 
listen:
# (control.Control) 
control:
# (access.Access) 
access:
# (access.Type) 
type:
# (access.Permission) 
permission:
# (string) 
pemFile:
# (access.FilePermission) 
pemFilePermission:
# (string) 
pemFileUser:
# (logger.Logger) 
logger:
# (logger.Level) Minimal log level the logger will output its messages.
level: info
# (logger.Level) If the service prints something to stdout instance will logged with instance level.
stdoutLevel: info
# (logger.Level) If the service prints something to stderr instance will logged with 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:
<service name>:
# (logger.Logger) 
logger:
# (logger.Level) Minimal log level the logger will output its messages.
level: info
# (logger.Level) If the service prints something to stdout instance will logged with instance level.
stdoutLevel: info
# (logger.Level) If the service prints something to stderr instance will logged with 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) 
command:
# (service.Type) 
type:
# (service.CronExpression) 
cronExpression:
# (int) 
startDelayInSeconds:
# (int) 
restartDelayInSeconds:
# ([]values.ExitCode) 
successExitCodes:
# (values.Signal) 
stopSignal:
# (int) 
stopWaitInSeconds:
# (string) 
user:
# ([string]string) 
environment:
<environment name>:
# (string) 
directory:
# (values.RestartType) 
autoRestart:
# (bool) 
inheritEnvironment:
# (access.Access) 
access:
# (access.Type) 
type:
# (access.Permission) 
permission:
# (string) 
pemFile:
# (access.FilePermission) 
pemFilePermission:
# (string) 
pemFileUser:

Data Types

Caretakerd object

This is a comment for config

Properties

access.Access object

Properties

access.FilePermission uint32

access.Permission enum

Elements

access.Type enum

Elements

control.Control object

Properties

keyStore.KeyStore object

Description

Defines the keyStore of caretakerd.

Properties

keyStore.Type enum

Description

Represents the type of the keyStore.

Elements

logger.Logger object

Description

A logger handles every output generated by the daemon itself, the process or other parts controlled by the daemon.

Properties

logger.Level enum

Description

Represents a level for logging with a Logger

Elements

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.

Let the conversion pattern be “%d{YYYY-MM-DD HH:mm:ss} [%-5p]: %m%n” and assume that the log4j environment was set to use a PatternLayout. Then the statements:

LOG debug Message 1
LOG warn Message 2

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 date of when the log event was created. See https://github.com/eknkc/dateformat for more details.
  • %m: The log message.
  • %c[{<maximumNumberOfElements>}]: Holds the logging category. Normally instance is the name of the logger or the service. If you do not specify maximumNumberOfElements the full name is displayed. If instance is for example %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 instance event. If you do not specify maximumNumberOfPathElements the full file name is displayed. If instance is for example %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. If instance is for example %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 instance log message.
  • %r: Uptime of the logger.
  • %n: Prints out a new line character.
  • %%: Prints out a % character.

rpc.Rpc object

Properties

service.Service object

Properties

service.CronExpression string

service.Type enum

Elements

values.ExitCode int

This represents an exit value of a process.

values.RestartType enum

Description

This tells caretakerd what to do if a process ends.

Elements

values.Signal enum

Description

This represents a system signal.

Elements

values.SocketAddress string

Description

This represents a socket address in format <protocol>://<target>.

Protocols

  • tcp

    This address connects or binds to a TCP socket. The target should be of format <host>:<port>.

  • unix

    This address connects or binds to a UNIX file socket. The target should be the location of the socket file.

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.