Difference between revisions of "Systemd/Services"

From ArchWiki
Jump to: navigation, search
(tftpd)
(Icecast: has been added to package)
Line 286: Line 286:
 
Type=forking
 
Type=forking
 
ExecStart=/opt/logmein-hamachi/bin/hamachid
 
ExecStart=/opt/logmein-hamachi/bin/hamachid
 
[Install]
 
WantedBy=multi-user.target
 
</nowiki>}}
 
 
== Icecast ==
 
{{hc|/etc/systemd/system/icecast.service|<nowiki>
 
[Unit]
 
Description=Icecast Service
 
After=network.target         
 
 
[Service]
 
ExecStart=/usr/sbin/icecast -c /etc/icecast.xml
 
  
 
[Install]
 
[Install]

Revision as of 12:31, 16 August 2012

Template:Article summary start Template:Article summary text

Template:Article summary heading Template:Article summary wiki Template:Article summary end

Currently, systemd is mostly at feature parity with Arch's initscripts. However, a lot more testing is needed. If you would like to help out, you can fork the initscripts-systemd or systemd-arch-units git repos and submit pull requests for your additions. This wiki page can serve as a staging area for these files.

mysqld

Note: Mysqld requires an extra script to work properly. Remember to chmod +x /usr/bin/mysqld-post before attempting to start mysqld.service.
Note: You have to either reboot or use systemd-tmpfiles --create mysqld.conf for the tmpfile to take effect.
/etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server

[Service]
User=mysql
ExecStart=/usr/bin/mysqld --user=mysql
ExecStartPost=/usr/bin/mysqld-post
Restart=always

[Install]
WantedBy=multi-user.target
/usr/bin/mysqld-post
#!/bin/sh
while true; do
	response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
	echo "$response" | grep -q "mysqld is alive" && break
	sleep 1
done
/etc/tmpfiles.d/mysqld.conf
d /var/run/mysqld 0755 mysql mysql -

irexecd

/etc/systemd/system/irexecd.service

[Unit]
Description=LIRC irexec Daemon
Requires=lircd.service
After=lircd.service

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/irexec.conf
ExecStart=/usr/bin/irexec --daemon $IREXEC_OPTS

[Install]
WantedBy=multi-user.target

References:

lircd

/etc/systemd/system/lircd.service

[Unit]
Description=LIRC Daemon
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lircd.conf
PIDFile=/run/lirc/lircd.pid
ExecStartPre=/bin/mkdir -p /run/lirc
ExecStartPre=/bin/rm -f /dev/lircd
ExecStartPre=/bin/rm -f /run/lirc/lircd
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd

ExecStart=/usr/sbin/lircd -d $LIRC_DEVICE -P /run/lirc/lircd.pid -H $LIRC_DRIVER $LIRC_CONFIGFILE
ExecStopPost=/bin/rm -f /dev/lircd
ExecStopPost=/bin/rm -fR /run/lirc

[Install]
WantedBy=multi-user.target
Note: $LIRC_EXTRAOPTS set in /etc/conf.d/lircd.conf will not work, as lircd will print an error about the argument count. Any extra options should be hardcoded into the unit file.

References:

rc.local

/etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Note: Also available through the unrecommended initscripts-systemd (see: Systemd#Arch_integration).

apache2

Note: You have to either reboot or use systemd-tmpfiles --create httpd.conf for the tmpfile to take effect.
/etc/systemd/system/httpd.service
[Unit]
Description=Apache Webserver
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/apache
ExecStart=/usr/sbin/httpd -k start $OPTIONS
ExecStop=/usr/sbin/httpd -k graceful-stop $OPTIONS
ExecReload=/usr/sbin/httpd -k graceful $OPTIONS
Restart=always

[Install]
WantedBy=multi-user.target
/etc/tmpfiles.d/httpd.conf
D /var/run/httpd 0755 http http -

memcached

/etc/systemd/system/memcached.service
[Unit]
Description=memcached daemon
After=network.target

[Service]
EnvironmentFile=/etc/conf.d/memcached
PIDFile=/var/run/memcached.pid
ExecStart=/usr/bin/memcached -d -P /var/run/memcached.pid -u $MEMCACHED_USER $MEMCACHED_ARGS
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

Static ethernet network

This is a custom service file for static ethernet configurations. For other configurations, see Systemd#Network

/etc/conf.d/network
interface=eth0
address=192.168.0.1	
netmask=24	
broadcast=192.168.0.255	
gateway=192.168.0.254
/etc/systemd/system/network.service
[Unit]	
Description=Network Connectivity	
Wants=network.target	
Before=network.target
	
[Service]	
Type=oneshot	
RemainAfterExit=yes	
EnvironmentFile=/etc/conf.d/network	
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}	
ExecStop=/sbin/ip link set dev ${interface} down
	
[Install]	
WantedBy=multi-user.target

Remote filesystem mounts

See: Systemd#Remote_filesystem_mounts

distccd

/etc/systemd/system/distccd.service
[Unit]
Description=distcc

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/distccd
ExecStart=/usr/bin/distccd --daemon $DISTCC_ARGS
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

Verynice

/etc/systemd/system/verynice.service
[Unit]
Description=A tool for dynamically adjusting the nice-level of processes

[Service]
Type=forking
PIDFile=/var/run/verynice.pid
ExecStart=/usr/sbin/verynice -d /var/run/verynice.pid
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

cpufreq

/etc/systemd/system/cpufreq.service
[Unit]
Description=CPU frequency scaling daemon

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/cpufreq
ExecStart=/usr/bin/cpufreq-set -r -g $governor -d $min_freq -u $max_freq

[Install]
WantedBy=multi-user.target

This sets the governor of all cores to the one specified in /etc/conf.d/cpufreq.

If you use the freq option, use to the following instead:

/etc/systemd/system/cpufreq.service
[Unit]
Description=CPU frequency scaling daemon

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/cpufreq
ExecStart=/usr/bin/cpufreq-set -r -f $freq

[Install]
WantedBy=multi-user.target

transmission daemon

Set User= to the user the daemon should run as.

/etc/systemd/system/transmissiond.service
[Unit]
Description=transmission daemon

[Service]
User=transmission
ExecStart=/usr/bin/transmission-daemon -f

[Install]
WantedBy=multi-user.target

BOINC Daemon

/etc/systemd/system/boinc.service
[Unit]
Description=BOINC Daemon

[Service]
User=boinc
Nice=19
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc --redirectio

[Install]
WantedBy=multi-user.target

Logmein Hamachi

/etc/systemd/system/hamachi.service
[Unit]
Description=Hamachi Daemon
After=network.target

[Service]
Type=forking
ExecStart=/opt/logmein-hamachi/bin/hamachid

[Install]
WantedBy=multi-user.target

tftpd

/etc/systemd/system/tftp.service
[Unit]
Description=Tftp Server
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/tftpd
ExecStart=/usr/sbin/in.tftpd $TFTPD_ARGS
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

See also

systemd