User Tools

Site Tools


systemd

Systemd

Two examples of how to stuff as daemons on a Unix server using Systemd.

IPython Notebook

Here, the IPython notebook is installed through Anaconda in user's path.

:!: The trick here is to use the Environment directive to load Anaconda :!:

$ vim /usr/lib/systemd/system/ipython-notebook.service

# README:                                                                                                                                                  
# Copy this file to /usr/lib/systemd/system/
# sudo systemctl daemon-reload
# systemctl enable ipython-notebook 
# systemctl start ipython-notebook
# The WorkingDirectory and ipython-dir must exist
# If you don't want anything fancy, go to http://127.0.0.1:8888 to see your notebook
# wheneber you want it

[Unit]
Description=IPython Notebook

[Service]
Environment="PATH=/somehome/user/Anaconda/bin:$PATH"
ExecStart=/home/someuser/Anaconda/bin/ipython notebook --profile nbserver
User=someuser
Group=someuser
WorkingDirectory=/home/someuser/Source/Notebooks

[Install]
WantedBy=multi-user.target

Then run

$ systemctl daemon-reload
$ systemctl enable ipython-notebook 
$ systemctl start ipython-notebook

Merlin Planetarion Bot

Same story as above. We assume the bot resides in the directory merlin and runs as the user merlin.

:!: Here, the trick is to direct merlin's output to /dev/null, so it doesn't spam the syslog. :!:

$ vim /usr/lib/systemd/system/merlin.service

# README:
# Copy this file to /usr/lib/systemd/system/
# sudo systemctl daemon-reload                                                                                                                             
# systemctl enable merlin
# systemctl start merlin

[Unit]
Description=Merlin

[Service]
ExecStart=/usr/bin/python /home/merlin/merlin/merlin.py
User=merlin
Group=merlin
WorkingDirectory=/home/merlin/merlin
StandardOutput=null

[Install]
WantedBy=multi-user.target

$ systemctl daemon-reload
$ systemctl enable ipython-notebook 
$ systemctl start ipython-notebook

systemd.txt · Last modified: 2015/06/03 20:04 by Volker