Skip to content

Instantly share code, notes, and snippets.

@thiagooak
Created November 1, 2013 12:56
Show Gist options
  • Save thiagooak/7265027 to your computer and use it in GitHub Desktop.
Save thiagooak/7265027 to your computer and use it in GitHub Desktop.
Creating a Daemon on CentOS 5 using DaemonTools
# daemontools on centos 5
# based on http://cr.yp.to/daemontools/install.html
# install
mkdir -p /package && chmod 1755 /package && cd /package
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
gunzip daemontools-0.76.tar && tar -xpf daemontools-0.76.tar && cd admin/daemontools-0.76
# centos 5 fix
echo 'gcc -include /usr/include/errno.h -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings' > src/conf-cc
package/install
# create test daemon
echo '<?php while(true) { sleep(1); }' > /test.php
# create test service
cat > /etc/service/test/run << EOF
#!/bin/sh
echo starting daemon
date -u
exec /usr/bin/php /test.php
EOF
# start to supervise
cd /etc/service
/usr/local/bin/supervise /etc/service/test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment