Installs DJB's Daemontools and includes a service custom resource.
Tested via Test Kitchen.
- Ubuntu 20.04
- CentOS 7, 8
- AmazonLinux 2
- Gentoo
- ArchLinux
This cookbook is known in the past to work on ArchLinux and Gentoo, but as they are rolling release distributions, it is difficult to ensure compatibility over time.
May work on other platforms with or without modification using the "source" installation method. See Attributes and Recipes below.
- pacman - for
aurrecipe, on ArchLinux systems - build-essential - for
sourcerecipe
node['daemontools']['bin_dir']- Sets the location of the binaries for daemontools, default is selected by platform, or '/usr/local/bin' as a fallback.node['daemontools']['service_dir']- Daemontools "service" directory where svscan will find services to manage.node['daemontools']['install_method']- how to install daemontools, can besource,packageoraur(for ArchLinux).node['daemontools']['start_svscan']- whether to startsvscan(includes thesvscanrecipe),trueby default.node['daemontools']['package_name']- name of the "daemontools" package, default value varies by platform.
The default recipe includes the appropriate installation method's recipe using the node['daemontools']['install_method'] attribute.
If the start_svscan attribute is true, then include the svscan recipe too.
Installs the daemontools package, using the node['daemontools']['package_name'] attribute. On Debian family systems, this is daemontools-run, which depends on daemontools (and provides run time / init system configuration).
On other untested platforms (e.g., RHEL family), if a local daemontools package is built and it sets up the appropriate init system configuration (systemd, upstart, inittab), then this recipe will be sufficient. Otherwise, write a custom recipe.
Used on ArchLinux systems to install daemontools from the Arch User Repository (AUR). Exits gracefully without exception if used on other platforms.
The source installation of daemontools should work on most other platforms that do not have a package available. A custom recipe may be required to configure the svscan service init script or upstart or systemd configuration.
Enables and starts the svscan service. This requires that the local system have properly set up the svscan service for the appropriate init system. It's outside the scope of this cookbook to detect this for every possible platform, so a custom recipe may be required. For example, Debian family daemontools-run package provides this.
This cookbook includes a custom resource, daemontools_service, for managing services with daemontools. Examples:
daemontools_service "tinydns-internal" do
directory "/etc/djbdns/tinydns-internal"
template false
action [:enable,:start]
end
daemontools_service "chef-client" do
directory "/etc/sv/chef-client"
template "chef-client"
action [:enable,:start]
log true
endDaemontools itself can perform a number of actions on services. The following are commands sent via the svc program. See its man page for more information.
- start, stop, status, restart, up, down, once, pause, cont, hup, alrm, int, term, kill
Enabling a service (:enable action) is done by setting up the directory located by the directory resource attribute. The following are set up:
runscript that runs the service startup using thetemplateresource attribute name.log/rundirectory and script that runs the logger if the resource attributelogis true.finishscript, if specified using thefinishresource attributeenvdirectory, containing ENV variables if specified with theenvresource attribute- links the
node['daemontools']['service_dir']/service_nameto theservice_namedirectory.
The default action is :start - once enabled daemontools services are started by svscan anyway.
The name attribute for the resource is service_name.
Include the daemontools recipe on nodes that should have daemontools installed for managing services. Use the daemontools_service custom resource for any services that should be managed by daemontools. In your cookbooks where daemontools_service is used, create the appropriate run and log-run scripts for your service. For example if the service is "flowers":
daemontools_service "flowers" do
directory "/etc/sv/flowers"
template "flowers"
action [:enable, :start]
log true
endCreate these templates in your cookbook:
templates/default/sv-flowers-run.erbtemplates/default/sv-flowers-log-run.erb
If your service also has a finish script, set the resource attribute finish to true and create sv-flowers-finish.erb.
The content of the scripts should be appropriate for the "flowers" service.
This project exists thanks to all the people who contribute.
Thank you to all our backers!
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.