NAME
cfkd - the supervisor process for ControlFreak
SYNOPSIS
cfkd [options]
Options:
--home=<directory> Path to cfkd home directory [default: $HOME/.controlfreak]
-a, --address=<socket address>
Path to UNIX socket file or address of INET socket
e.g: unix:/tmp/cfkd.sock or localhost:11311
[default: $home/sock]
-l, --log-config-file=<file>
Path to cfkd log config file, cfkd will attempt to create
a default config file if the file doesn't exist.
[default: $home/log.config]
-d, --daemon Run as a daemon
-t, --trap Trap and ignore normal signals (ignored unless -d)
-h, --help Help
-m, --man More help
OPTIONS
Please see SYNOPSIS.
DESCRIPTION
cfkd supervises other processes, making sure there are up or down when you want to, and provides flexible logging facility for those services.
SAMPLE CONFIG
service memcached cmd = /usr/bin/memcached -p 11211
service memcached ignore_stderr = 1
service memcached tags = prod
service memcached-test cmd = /usr/bin/memcached -p 12221
service memcached tags = test,optional
service perlbal cmd = /usr/bin/perlbal -c /etc/perlbal.conf
service perlbal tags = prod
socket fcgisock address = 127.0.0.1:8080
socket fcgisock listen_qsize = 1024
## webNNN share a common socket through their stdin
service web001 cmd = /usr/bin/plackup -a /home/www/app.psgi -s FCGI
service web001 tie_stdin_to = fcgisock
service web001 tags = prod,webs
service web002 cmd = /usr/bin/plackup -a /home/www/app.psgi -s FCGI
service web002 tie_stdin_to = fcgisock
service web002 tags = prod,webs
# start random stuff
command up svc memcached
command up svc perlbal
SAMPLE LOG CONFIG
ControlFreak works with Log::Log4perl framework which is incredibly flexible. You might have to install additional modules to get the most of your logging experience (let's say if you want to be notified by Instant Message of services going down).
There are two categories of logger:
- the main logger
-
This is the logger used by ControlFreak itself, it allows to finely control what do you want to log from what's happening in
cfkd
. - the service logger
-
This is a serie of loggers used by the different services. All services will get by default their
stdout
andstderr
aggregated and logged, unless you specify theignore_stderr
andignore_stdout
options.Each log event gets assigned the following log category:
service.$service_name.$type
Where
$service_name
is the name of your service ("worker001", "perlbal") and $type is eithererr
orout
.Obviously messages going to
stderr
will be logged at levelERROR
while messages onstdout
will be logged atINFO
level.
Service cspec/placeholder
ControlFreak defines a special cspec %S
representing the service pid. (which only makes sense in the service logger).
Log Config Sample 2
## logs everything under cfk's home
log4perl.rootLogger=DEBUG, LOGFILE
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/home/user/.controlfreak/cfkd.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=%d [%S] %p %c - %m%n
Log Config Sample 2
# daemon log to the main log
log4perl.rootLogger=DEBUG, LOGFILE
# all services to service logs...
log4perl.logger.service=DEBUG, SVCFILE
log4perl.additivity.service = 0
# ...but gearman errors are also going to the screen
log4perl.logger.service.gearmand=ERROR, SCREEN
log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
log4perl.appender.SCREEN.layout=PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern=[gearman] %p %c - %m%n
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/tmp/main.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
# %S = service pid
log4perl.appender.LOGFILE.layout.ConversionPattern=%S %p %L %c - %m%n
log4perl.appender.SVCFILE=Log::Log4perl::Appender::File
log4perl.appender.SVCFILE.filename=/tmp/services.log
log4perl.appender.SVCFILE.mode=append
log4perl.appender.SVCFILE.layout=PatternLayout
log4perl.appender.SVCFILE.layout.ConversionPattern=%S %p %L %c - %m%n