start_asterisk and systemd

ArchLinux adopted systemd as its init system quite a while ago. Then earlier this year the Debian “committee” voted to adopt systemd as its default init system, with Ubuntu soon adopting the same. For me it was a little painful going from init to systemd since I, like so many others, was comfortable/familiar with init, which has served the Linux/Unix community well for many decades. There has been some sentiment of “if it aint broken don’t fix it”, but be that as it may, systemd is coming.

As I am testing Asterisk-12 and FreePBX-12 on ArchLinux, I continue to use start_asterisk and have disabled the systemd asterisk.service for now. Certainly the start_asterisk script works fine, but at some point the FreePBX development group may wish to investigate systemd. For reference, below is an example of a systemd asterisk.service script for starting/stopping/restarting asterisk. I just wanted to share this information for reference and am very excited about the great work in FreePBX-12.

[Unit]
Description=Asterisk PBX and telephony daemon
Documentation=man:asterisk(8)
Wants=network.target
After=network.target

[Service]
Type=simple
User=asterisk
Group=asterisk
ExecStart=/usr/bin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/bin/asterisk -rx ‘core stop now’
ExecReload=/usr/bin/asterisk -rx ‘core reload’

# safe_asterisk emulation
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

We can’t take any code, even simple or potentially obvious snippits without a CLA.
http://wiki.freepbx.org/display/DC/Code+License+Agreement

That said there is background stuff happening and Centos 7 is on our radar including systemd, firewalld etc. Some of this is still a bit off as we focus on FreePBX 12. That said we love contributions. If you are willing to do the CSA above you can attach this to a feature request at http://issues.FreePBX.org to be considered for inclusion.

The file asterisk.service is part of the Asterisk-12 package in the ArchLinux AUR (Arch User Repository) it installs automatically as part of pacman -Sy asterisk, like an apt-get in Debian/Ubuntu if those Linux flavors actually had a native compile of Asterisk.

I posted it here as a reference appendix to my post about where the major flavors of Linux are headed with init and systemd. I just wanted to give a “heads up” to the FreePBX development group and supply an example because learning systemd is a whole new way of initializing applications compared to init, but I assumed the FreePBX development group would probably develop its own asterisk.service if it decided to embrace systemd.