Profile Picture

Hi, I'm Sheeju Alex.

I'm a developer, living in Bangalore, India and this is my personal development blog. I plan to share my technical stuff here, long back but not so long back I used to share my technical and crazy stuff on Sheeju Alex, Blog Spot.

Shoot me an email if you'd like to be in touch.

Check out my Resume here

Sheeju Alex

Running services using daemontools

Daemontools is the best way to manage your processes that is required to be running always. If you have processes like catalyst development server or spooler process that are required to be running always and needs to be self sustainable if they are killed for some reason.

Why Daemontools

  inittab ttys init.d rc.local /service
Easy service installation and removal No No Yes No Yes
Easy first-time service startup No No No No Yes
Reliable restarts Yes Yes No No Yes
Easy, reliable signalling No No No No Yes
Clean process state Yes Yes No No Yes
Portability No No No No Yes

Installing daemontools

Installing daemontools on Ubuntu - Version 1

apt-get install daemontools dameontools-run

This will install and setup autostart of svscanboot on system boot via /etc/inittab


Installing daemontools on Ubuntu - Version 2

  1. Install daemontools
apt-get -y install daemontools
  1. Create /etc/service directory
mkdir -p /etc/service
  1. need to make a conf file for booting
cd /etc/init/
touch svscan.conf

echo "start on runlevel [2345]" > svscan.conf
echo "" >> svscan.conf
echo "expect fork" >> svscan.conf
echo "respawn" >> svscan.conf
echo "exec svscanboot" >> svscan.conf
  1. Start svscan service
service svscan start
  1. That’s it. Now you can check it using command below:
ps -ef|grep svscan

Installting daemontools on Centos

  1. Install wget gcc and wget
    yum install gcc wget
  1. Create a folder setup and wget the source
   mkdir -p /package
   chmod 1755 /package
   cd /package
   tar -xzvf daemontools-0.76.tar.gz
   rm daemontools-0.76.tar.gz
  1. Install the daemontools
   echo gcc -O2 -include /usr/include/errno.h > src/conf-cc
  1. Fix Deamontools for CentOS 6.x. To do that simply remove the added line from /etc/inittab then issue this:
    echo "start on runlevel [12345]" > /etc/init/svscan.conf
    echo "respawn" >> /etc/init/svscan.conf
    echo "exec /command/svscanboot" >> /etc/init/svscan.conf
  1. Start svscan service
    initctl reload-configuration
    initctl start svscan
  1. That’s it. Now you can check it using command below:
    ps -ef|grep svscan

Creating service

  1. Create /services directory where we store all our services
mkdir /services

mkdir /services/catalystd
  1. Run file for catalystd

Create a file run inside /services/catalystd directory


echo `date`."\n"
echo "\catalystd: Starting\n"

exec 2>&1

echo "catalystd: Setting ENV Variables\n"
export CATALYSTAPP_WWW_ROOR="/home/sheeju/projects/CatalystApp"
export PERL5LIB=/home/sheeju/projects/lib/:${PERL5LIB}
export PGSERVICEFILE=/home/sheeju/projects/pg_service.conf

exec /usr/bin/perl \

  1. Run file for catalystd log

#exec cat > /var/log/parserspoold/test.log
multilog t n100 s16777215 /var/log/catalystd 2>&1

Daemontools Commands

  1. Start service
ln -s /services/catalystd /etc/service
  1. Remove service
rm /etc/service/catalystd
svc -dx /services/somerandomservice
  1. Restart service
svc -t /service/somerandomservice
svc -k /service/somerandomservice
  1. Check service uptime
sudo svstat /etc/service/catalystd
/etc/service/catalystd: up (pid 772) 349 seconds
  1. Checking the logs
tail -f /var/log/catalystd/current
  1. Checking the running processes
ps auxf
pstree -a 15234


comments powered by Disqus