Closed gelbbauch closed 3 years ago
Oh thats awesome! I personally never messed with systemd. So thats cool!
Easier way to to it:
`cat << EOF > /etc/systemd/system/valheim.service [Unit] Description=Valheim game server
[Service] Type=forking ExecStart=/usr/bin/ansible-playbook /opt/server/game-ansible/valheim/start.yml --extra-vars '{"app_dir":"/opt/server","name":"Wastaken","world":"Dedicated","public":"1","password":"4Valhalla!", "port":"2456"}' ExecStop=/usr/bin/ansible-playbook /opt/server/game-ansible/valheim/stop.yml Type=oneshot RemainAfterExit=yes
[Install] WantedBy=multi-user.target EOF`
then:
systemctl daemon-reload
and
systemctl enable --now valheim.service
... to run the service on boot and start it now, all of the above ran with sudo/root permissions.
Is this something you wanted implemented or is this documentation purposes?
It's up to you. I made it and use it, technically don't need this documented anymore, but I thought others might like to use systemd with the service so you can enable the server to run on boot. At least it's here if anyone else want to use it.
root@valheim:/etc/systemd/system# cat valheim.service [Unit] Description=Valheim game server
[Service] Type=forking ExecStart=/usr/bin/ansible-playbook /opt/server/game-ansible/valheim/ansible-playbook start.yml --extra-vars '{"app_dir":"/opt/server","name":"ServerName","world":"Dedicated","public":"1","password":"secret", "port":"2456"}' ExecStop=/usr/bin/ansible-playbook /opt/server/game-ansible/valheim/stop.yml Type=oneshot RemainAfterExit=yes
[Install] WantedBy=multi-user.target