HOWTO: Make Serviio auto-start under Linux (Red Hat, Fedora,
For new Linuces, the old System V / init.rc approach is no longer used. Linux flavors derived from Red Hat (Fedora, CentOS, others) now use SystemD, and its control / inspection utility, systemctl.
Let's say you don't want to do a deep dive into systemd and systemctl, you just want to provide a more systematic way of starting / stopping Serviio, and make sure it starts on boot without any intervention. Oh, and it shouldn't start up until the machine's network is up & running. You don't want to have to learn overmuch about systemd units, targets, wants, and all the other systemd terminology.
I'm your guy.
First, these instructions were developed on a Fedora 28 machine, in August 2018. If you're not using a Red Hat derived system, odds are this won't work for you. To see if it will, look for the first clue. Become root (use su -) and run the commands below as root. If you get a huge list of devices, services, targets, and stuff, then you're on the right track.
Then go to the /etc/systemd/system directory and see what's in there:
You should see some "services" and some "wants" and some other stuff. Specifically, you're looking for multi-user.target.wants a directory that represents stuff that should be started up as a result of the system reaching the multi-user run-state, meaning that networking and other multi-user support has started up. Don't tinker (directly) with anything in multi-user.target.wants
Below, you use an editor to create and update a system config file. That means vi, vim, emacs, elm, pine, nano, gedit, or similar. If you use a word processor and mangle the file, don't even ask- it's not going to work. I think kwrite works too.
Next, fire up your favorite editor (real men use vi right?) and create /etc/systemd/system/serviio.service and type the parameters shown into it: and the contents should be:
It says
Now, if you want Serviio to be loaded every time the machine boots, reaches the network up and multi-user states, enable it:
Whether or not it's "enabled" you can still stop it, start it, or check it's status:
Keep in mind that starting and stopping it won't change it's enabled (or not enabled) state. You have to usefor that.
This is a really basic simplistic systemd unit file, and a lot more could be done with it. Perhaps I'll update this as I discover new stuff.
Let's say you don't want to do a deep dive into systemd and systemctl, you just want to provide a more systematic way of starting / stopping Serviio, and make sure it starts on boot without any intervention. Oh, and it shouldn't start up until the machine's network is up & running. You don't want to have to learn overmuch about systemd units, targets, wants, and all the other systemd terminology.
I'm your guy.
First, these instructions were developed on a Fedora 28 machine, in August 2018. If you're not using a Red Hat derived system, odds are this won't work for you. To see if it will, look for the first clue. Become root (use su -) and run the commands below as root. If you get a huge list of devices, services, targets, and stuff, then you're on the right track.
Then go to the /etc/systemd/system directory and see what's in there:
You should see some "services" and some "wants" and some other stuff. Specifically, you're looking for multi-user.target.wants a directory that represents stuff that should be started up as a result of the system reaching the multi-user run-state, meaning that networking and other multi-user support has started up. Don't tinker (directly) with anything in multi-user.target.wants
Below, you use an editor to create and update a system config file. That means vi, vim, emacs, elm, pine, nano, gedit, or similar. If you use a word processor and mangle the file, don't even ask- it's not going to work. I think kwrite works too.
Next, fire up your favorite editor (real men use vi right?) and create /etc/systemd/system/serviio.service and type the parameters shown into it: and the contents should be:
It says
- * You're defining a systemd "Unit"
* It has a description as shown
* It should be loaded after the network target is successfully loaded
* It's a service
* It should be started by executing the script mentioned by the ExecStart line. Don't forget to adjust this for where your serviio.sh script is actually located!
* And that the muli-user state wants it to be loaded.
Now, if you want Serviio to be loaded every time the machine boots, reaches the network up and multi-user states, enable it:
Whether or not it's "enabled" you can still stop it, start it, or check it's status:
- Code:
# systemctl status serviio
● serviio.service - Serviio DLNA media streaming server
Loaded: loaded (/etc/systemd/system/serviio.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-08-22 20:03:50 CDT; 44min ago
Main PID: 29556 (java)
Tasks: 122 (limit: 4915)
Memory: 918.4M
CGroup: /system.slice/serviio.service
└─29556 java -Xmx2048M -Xms1024M -XX:+UseG1GC -XX:GCTimeRatio=1 -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -Djava.net.preferIPv4Stack=true >
Aug 22 20:03:50 clarke.localdomain systemd[1]: Started Serviio DLNA media streaming server.
Aug 22 20:03:50 clarke.localdomain serviio.sh[29556]: Serviio Media Server
# systemctl start serviio.service
# systemctl stop serviio.service
Keep in mind that starting and stopping it won't change it's enabled (or not enabled) state. You have to usefor that.
This is a really basic simplistic systemd unit file, and a lot more could be done with it. Perhaps I'll update this as I discover new stuff.