Log in

View Full Version : systemctl startup/shutdown script


Yummy
06-10-2015, 04:57 PM
Does anyone have an example of a systemd startup and shutdown script?

Fedora/CentOS move from sys-v to systemd has left me feeling a bit lost. :)

Thank you

Flopz
08-10-2015, 06:36 PM
Here are what I'm using for mine

# cat /usr/lib/systemd/system/eqemu-world.service
[Unit]
Description=EQ Emulator World server
After=network.target

[Service]
Type=simple
User=eq
Group=users
WorkingDirectory=/home/eq/server
ExecStartPre=/home/eq/server/shared_memory
ExecStart=/home/eq/server/world

[Install]
WantedBy=multi-user.target

# cat /usr/lib/systemd/system/eqemu-zones.service
[Unit]
Description=EQ Emulator Zone server
After=network.target
After=eqemu-world.service
Requires=eqemu-world.service

[Service]
Type=simple
User=eq
Group=users
WorkingDirectory=/home/eq/server
ExecStart=/home/eq/server/eqlaunch zone

[Install]
WantedBy=multi-user.target

EDIT: This is on CentOS 7. I'd imagine would work fine on Fedora without modifying (beyond changing the paths, that is)

jpyou127
08-19-2015, 11:55 AM
Would this work on Ubuntu? And how is the service called at bootup?

I have systemd with systemd-shim.list, but the directory structure in the above scripts are different.

Yummy
09-06-2015, 05:48 PM
Here are what I'm using for mine


Thank you! I will give it a go and let you know the results.

Yummy
09-06-2015, 08:19 PM
Here are what I'm using for mine

I had to make some minor changes but your examples were perfect as a starting point. You saved me hours and hours. Thank you!

For Fedora 22, I chose to create five systemd scripts. The those unfamiliar with the process, I have provided details here https://blog-harmonson.rhcloud.com/2015/06/08/eqemu-on-fedora-22-server-minimal/ under the section titled Systemd Scripts.


eqemu-loginserver.service

[Unit]
Description=EQ Emulator Login server
After=mysqld.service
Requires=mysqld.service

[Service]
Type=simple
User=eqadmin
Group=users
WorkingDirectory=/home/eqadmin/eqemu/server
ExecStart=/home/eqadmin/eqemu/server/loginserver

[Install]
WantedBy=multi-user.target



eqemu-world.service

[Unit]
Description=EQ Emulator World server
After=eqemu-loginserver.service
Requires=eqemu-loginserver.service

[Service]
Type=simple
User=eqadmin
Group=users
WorkingDirectory=/home/eqadmin/eqemu/server
ExecStartPre=/home/eqadmin/eqemu/server/shared_memory
ExecStart=/home/eqadmin/eqemu/server/world

[Install]
WantedBy=multi-user.target


eqemu-queryserv.service


[Unit]
Description=EQ Emulator Query server
After=eqemu-world.service
Requires=eqemu-world.service

[Service]
Type=simple
User=eqadmin
Group=users
WorkingDirectory=/home/eqadmin/eqemu/server
ExecStart=/home/eqadmin/eqemu/server/queryserv

[Install]
WantedBy=multi-user.target


eqemu-ucs.service

Unit]
Description=EQ Emulator UCS server
After=eqemu-queryserv.service
Requires=eqemu-world.service

[Service]
Type=simple
User=eqadmin
Group=users
WorkingDirectory=/home/eqadmin/eqemu/server
ExecStart=/home/eqadmin/eqemu/server/ucs

[Install]
WantedBy=multi-user.target


eqemu-zones.service

[Unit]
Description=EQ Emulator Zone server
After=eqemu-ucs.service
Requires=eqemu-world.service

[Service]
Type=simple
User=eqadmin
Group=users
WorkingDirectory=/home/eqadmin/eqemu/server
ExecStart=/home/eqadmin/eqemu/server/eqlaunch zone

[Install]
WantedBy=multi-user.target