How to make a systemd service to start your server after system boot
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.
|