vNextIn the previous article I've used nohup + su + init.d script to run kestrel in a background. But as Daniel Lo Nigro suggested in comments it's much easier to do the same with Supervisor

And he was absolutelly right, config is much smaller, and you can easelly see status and output of a program.

First, install supervisor:

sudo apt-get install supervisor

Now you can create config for your application:

sudo nano /etc/supervisor/conf.d/kestrel_default.conf

With following content:

[program:kestrel_default]
command=su -c "/home/username/.k/runtimes/kre-mono.1.0.0-beta3/bin/k kestrel" username
directory=/home/username/mvc/HelloMvc
autorestart=true
autostart=true
stdout_logfile=/home/username/mvc/HelloMvc/logs/app_std_out.log
stderr_logfile=/home/username/mvc/HelloMvc/logs/app_err.log

Specify path to your dnx and application, as well as username under which you want to run your application (usually user who has dnx installed)

Now you can tell supervisor to reread configurations:

sudo supervisorctl reread
sudo supervisorctl update

This command will automaticaly start your application (we specified autostart=true in config).

To see current status and start\stop applications execute:

sudo supervisorctl

There you can stop application:

stop kestrel_default

Start:

start kestrel_default

Or check program's output:

tail kestrel_default