Life with systemd Part 2

Posted on Thu 15 November 2012 in misc

systemd rocks!  I really did not think I had the patience to learn it, but now I understand it and have played about with it, I think it is brilliant if not for one reason alone - creating service files are trivial, which is how it should be.  In SysVInit I rarely bothered.

Here's one I knocked up for icecast.  There was already a rc script for it running under under systemd but I decided to create my own systemd service file as a test.  To install was was simply a matter of:-

systemctl stop icecast.service 

systemctl disable icecast.service

cp icecast.service /lib/systemd/system/icecast.service,  

and then activating it again with systemctl enable icecast.service 

systemd realised it had a service file for it and uses that rather that the installed /etc/rc.d/icecast file which I could leave installed.  I'm impressed.

Here's the icecast.service file I created.  I had to uncomment the pid file option in icecast.xml.  I also changed the path to /var/run

[Unit]]
Description=Icecast 2.x Server]

[Service]
ExecStart=/usr/bin/icecast -b -c /etc/icecast.xml
Type=forking
PIDFile=/var/run/icecast.pid

[Install]
WantedBy=multi-user.target]