Debian Jessie at your service
Recently I needed to create custom server service on Debian Jessie (wich is version 8) and there is systemd used as a service system. Systemd is very complex but if you are not an expert, this brief article will show you simple way for creating general server service.
Topic: Create own systemd service
OS: Debian 8 (Jessie)
Tool: systemctl, service, vim
“systemctl” is basic command to work with systemd service. When executes, it lists all services. Just type:
Service definition files (on Debian 8) are located under /lib/systemd/system/. We just need to create a new one. Our newly created file will be /lib/systemd/system/myservice.service
Description=My custom service
Referenced sh scripts contain server execution instructions, “Type forking” provides daemon like process execution usually used with optional PIDFile. Here we need network service as a prerequisite and we expect scripts output available in syslog. This definition should work well for some terminal server service executed from script files. If you have another type of service, you’ll have to modify it according to your specific needs.
Here we are using “systemctl” but we can also use “service” command for hese obvious operations.
systemctl enable myservice
systemctl disable myservice
systemctl stop myservice
service myservice stop
systemctl start myservice
service myservice start
Service logging and status
To see log messages you can just read syslog content:
We can also check service status like this:
systemctl status myservice
That’s all, everything should work now. For more about systemd, check man pages.
Slaves, obey your earthly masters with fear and trembling, with a sincere heart, as you would Christ, not by the way of eye-service, as people-pleasers, but as servants of Christ, doing the will of God from the heart, rendering service with a good will as to the Lord and not to man, knowing that whatever good anyone does, this he will receive back from the Lord, whether he is a slave or free. (Ephesians 6:5)