PDA

View Full Version : How to make a systemd service to start your server after system boot


Gazebeaux
02-27-2022, 12:04 AM
I'm brand new to Linux and also a stupid idiot with a waste of a brain. But I figured something out, and in my googling I found lots of threads where people asked for help with this but I couldn't find an example that worked for me, so I came up with this:

[Unit]
Description=BoQ server

[Service]
Type=forking
User=boq
Group=users
WorkingDirectory=/home/eqemu/server
ExecStartPre=/bin/sleep 10
ExecStart=/home/eqemu/server/server_start.sh

[Install]
WantedBy=multi-user.target


the 2 most important parts of this for me were type=forking (instead of type=simple)and execstartpre/=/bin/sleep 10. I have no idea wtf forking means but the way I understand it is when you run a script and it keeps running a process in the background but the prompt returns, that requires forking. When I used simple, it ended the process but still reported success in the log because technically it was a success, simple isn't used for processes that keep running (that's how i understand it, could be wrong, don't hurt me)

execstartpre/=/bin/sleep 10 creates a 10 sec delay after booting before it runs the server. It wouldn't work without this for me because it hadn't completed its mySQL connection before it tried running the server.

Don't let Linux scare you. There's more than enough info online to figure it and there are big advantages to using it over windows, for me the primary one being that it's cheaper to rent a server that runs on it lol. Thanks to Akkadius and all who work on EQEmu and thanks to all those who answer questions here and on the discord. Y'all rock.

Freejack
02-28-2022, 04:45 AM
I'm brand new to Linux and also a stupid idiot with a waste of a brain. But I figured something out, and in my googling I found lots of threads where people asked for help with this but I couldn't find an example that worked for me, so I came up with this:

[Unit]
Description=BoQ server

[Service]
Type=forking
User=boq
Group=users
WorkingDirectory=/home/eqemu/server
ExecStartPre=/bin/sleep 10
ExecStart=/home/eqemu/server/server_start.sh

[Install]
WantedBy=multi-user.target


the 2 most important parts of this for me were type=forking (instead of type=simple)and execstartpre/=/bin/sleep 10. I have no idea wtf forking means but the way I understand it is when you run a script and it keeps running a process in the background but the prompt returns, that requires forking. When I used simple, it ended the process but still reported success in the log because technically it was a success, simple isn't used for processes that keep running (that's how i understand it, could be wrong, don't hurt me)

execstartpre/=/bin/sleep 10 creates a 10 sec delay after booting before it runs the server. It wouldn't work without this for me because it hadn't completed its mySQL connection before it tried running the server.

Don't let Linux scare you. There's more than enough info online to figure it and there are big advantages to using it over windows, for me the primary one being that it's cheaper to rent a server that runs on it lol. Thanks to Akkadius and all who work on EQEmu and thanks to all those who answer questions here and on the discord. Y'all rock.

Just to let you know the docker install takes care of all of this. the only issue I have is on a reboot. Docker never gets completely shutdown fast enough.

markusdabrave
02-28-2022, 04:02 PM
I really need to look into docker...

Freejack
03-01-2022, 02:39 AM
I really need to look into docker...

https://github.com/Akkadius/akk-stack


Complete install instructions and setup, works like a wine prefix. also doing this you get all the tools and monitoring capabilities. Updates are a breeze.