Skip to content

Instantly share code, notes, and snippets.

@avalanche123
Created June 6, 2012 00:55
Show Gist options
  • Save avalanche123/2879188 to your computer and use it in GitHub Desktop.
Save avalanche123/2879188 to your computer and use it in GitHub Desktop.
Common Daemon Interface
# Common Daemon Interface is a emerging standard, its only purpose is to define portable daemon specifications understandable and interchangeable between
# various service and process managers. Primary targets are launchd, upstart and systemd and the ones known to be widely used and fairly similar.
# Feedback welcome.
# required settings
SERVICE_NAME="my_cool_service" # alphanumeric string, underscores and dots are allowed
DAEMON_INTERFACE="CDI/1.0" # daemon interface version
SERVICE_TYPE="daemon" # (task|daemon) wether process is a one-time job or background daemon
# generic options, all optional
PROCESS_COMMAND="bundle exec rake test" # program to run, arguments inline
PROCESS_USER="bulat" # user to run the process under
PROCESS_GROUP="staff" # group to run the process under
PROCESS_ROOT_DIR="/srv/chroots/oneiric" # chroot
PROCESS_WORKING_DIR="/var/mydaemon" # chdir
PROCESS_UMASK="0775" # umask
SERVICE_SOCKET="tcp://127.0.0.1:5000" # socket is specified as a uri in form of <protocol>://<socket string>, <protocol> is one of (udp|tcp|unix)
SERVICE_SOCKET="unix:///path/to/unix/domain.socket" # <socket string> is ip:port for network sockets or just path for unix
SERVICE_SOCKET="tcp://127.0.0.1:5000,unix:///path/to/unix/domain.socket" # multiple sockets can be specified in a coma-separated list without trailing whitespace
# resource limits, refer to setrlimit(2)
LIMIT_CORE="5,0" # specified in a form of <soft limit>,<hard limit>
LIMIT_CPU="0" # hard limit is optional, same value should be used for both if only one value is supplied
LIMIT_DATA="0"
LIMIT_FSIZE="0"
LIMIT_MEMLOCK="0"
LIMIT_NOFILE="0"
LIMIT_NPROC="0"
LIMIT_RSS="0"
LIMIT_STACK="0"
@Rudd-O
Copy link

Rudd-O commented Jun 6, 2012

Also, you should probably post on the freedesktop mailing list where systemd devs congregate, to find common points and reuse same approaches. Also see http://www.freedesktop.org/wiki/Software/systemd/InterfacePortabilityAndStabilityChart to get an idea of what not to reimplement unnecessarily (just implement as compatibility).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment