Documentation > Administration > Going to Production > Automatic Startup and Restart

Automatic Startup and Restart

For running in production, you might want to:

  • automatically start at system boot as a daemon (background service)
  • automatically restart if it exits (either deliberately, or by accident)

There are different approaches and tools to accomplish above under Unix-like operating systems:


Create a systemd service file /etc/systemd/system/crossbar.service


ExecStart=/opt/crossbar/bin/crossbar start --cbdir=/home/ubuntu/mynode1/.crossbar


Adjust the path to the executable /opt/crossbar/bin/crossbar and your node directory /home/ubuntu/mynode1/.crossbar in above.

Then do:

sudo systemctl daemon-reload

To make start automatically at boot time:

sudo systemctl enable crossbar.service

To start, stop, restart and get status for

sudo systemctl start crossbar
sudo systemctl stop crossbar
sudo systemctl restart crossbar
sudo systemctl status crossbar

To get log output:

journalctl -f -u crossbar


Create an upstart job file /etc/init/crossbar.conf

description ""

start on runlevel [2345]
stop on runlevel [!2345]

respawn limit 20 5

setuid ubuntu
setgid ubuntu

env MYVAR1=foobar

exec /opt/crossbar/bin/crossbar start --cbdir=/home/ubuntu/mynode1/.crossbar

Adjust the path to the executable /opt/crossbar/bin/crossbar and your node directory /home/ubuntu/mynode1/.crossbar in above.

Then do

sudo initctl reload-configuration

To start, stop, restart and get status for

sudo start crossbar
sudo stop crossbar
sudo restart crossbar
sudo status crossbar

To get log output:

sudo tail -f /var/log/upstart/crossbar.log


The following describes how to monitor and restart automatically using Daemontools. Daemontools is a simple, effective, highly secure tool create by Dan Bernstein (aka "djb").

Note: There is also runit, which is a Daemontools clone that some people prefer.


To install Daemontools on Debian based systems (Ubuntu et al):

sudo apt-get install csh daemontools daemontools-run

This will install a couple of tools including



Create a Daemontools service directory for

sudo mkdir /etc/service/crossbar

Create a service run script

sudo vi /etc/service/crossbar/run

with the following content:


exec /usr/bin/setuidgid ubuntu \
   /home/ubuntu/pypy-2.2.1-linux64/bin/crossbar start \
   --cbdir /home/ubuntu/cbdemo/.crossbar \
   --logdir /home/ubuntu/cbdemo/.crossbar/log

Above assumes:

  • you are using PyPy under the specified path
  • you want to run under the dedicated Unix user ubuntu (which fits for a Amazon EC2 Ubuntu Server AMI)
  • you have a node created in the specified node directory
  • you want log to the specified subdirectory within the node directory

Make the run script executable:

sudo chmod +x /etc/service/crossbar/run

To make Daemontools start automatically at system boot:

sudo vi /etc/rc.local

and add the following to the end of that file:

/bin/csh -cf '/usr/bin/svscanboot &'

exit 0

Reboot your system and check the has been started:

ubuntu@ip-10-229-126-122:~$ sudo svstat /etc/service/crossbar
/etc/service/crossbar: up (pid 1006) 91391 seconds


To stop

sudo svc -d /etc/service/crossbar

To (manually) start again:

sudo svc -u /etc/service/crossbar

To restart:

sudo svc -t /etc/service/crossbar

To check status:

sudo svstat /etc/service/crossbar

By default - if given --logdir option - will create daily rotated log files in the directory specified:

ubuntu@ip-10-229-126-122:~$ ls -la /home/ubuntu/cbdemo/.crossbar/log
total 28
drwxr-xr-x 2 ubuntu ubuntu  4096 Mar 18 04:15 .
drwxrwxr-x 3 ubuntu ubuntu  4096 Mar 17 16:14 ..
-rw-r--r-- 1 ubuntu ubuntu  2737 Mar 18 08:13 node.log
-rw-r--r-- 1 ubuntu ubuntu 13915 Mar 17 16:14 node.log.2014_3_17

To watch the log file:

tail -f /home/ubuntu/cbdemo/.crossbar/log/node.log
remote management for
Test remote management for
Community Chat