Running ServUO as a service on Ubuntu 16.04 with auto restarts

  • If you would like to submit a tutorial please visit the main tutorial page here.
    You can not submit them from this forum.

Ixtabay

Well-Known Member
Mar 30, 2015
65
13
Spring, TX USA
Ixtabay created a new tutorial:

Running ServUO as a service on Ubuntu 16.04 with auto restarts
This is how to run ServUO as a service on your Ubuntu Server v16.04

First, you need to create the system file:
Code:
sudo nano /etc/systemd/system/servuo.service
Copy and paste this code:
(Note: you will need to set the WorkingDirectory and ExecStart paths according to your configuration)
Code:
[Unit]
Description=ServUO.MONO
After=network.target

[Service]
User=root
Type=simple
WorkingDirectory=/home/ubuntu/ServUO
ExecStart=/usr/bin/mono --server /home/ubuntu/ServUO.MONO.exe...
Read this tutorial...
 

rhasce

Well-Known Member
Jan 10, 2017
240
10
37
Shard Name
play.uoquest.com
Hello, all, I use this on a server and it works awesome, I just made a second server and I keep getting this:
servuo.service: start request repeated too quickly.

Any ideas? Thanks all.
[doublepost=1511832403][/doublepost]Can it be just me?
 

Ixtabay

Well-Known Member
Mar 30, 2015
65
13
Spring, TX USA
Sounds like it's starting and then crashing quickly after it starts. You might try adding a delay...
Code:
[Timer]
OnStartupSec=15

edited: told you wrong the first time, it's late :)
 
Last edited:

rhasce

Well-Known Member
Jan 10, 2017
240
10
37
Shard Name
play.uoquest.com
Thanks, I was leaving console open and I dont like that hehe :)
[doublepost=1512880211][/doublepost]Thas fine thanks so much :)
 

gobbly

New Member
Feb 18, 2019
1
0
40
Is `/home/ubuntu/ServUO.MONO.exe` supposed to be part of the distribution? I just get `Feb 18 21:00:20 ip-172-31-27-244 mono[17812]: Cannot open assembly '/home/ubuntu/ServUO.MONO.exe': No such file or directory.`
Doesn't seem to make a difference if I point to to `/home/ubuntu/ServUO.exe` I get the same error.
 

Zavreyon

Gold Donator
Apr 5, 2015
83
26
31
My execstart targets the 'ServUO.sh' file that was created following this tutorial, (however I did change paths slightly):

https://www.servuo.com/tutorials/yet-another-debian-servuo-tutorial.44/

Code:
ExecStart=/bin/sh -c '/usr/bin/screen -DmS servuo /srv/ServUO/ServUO.sh'
It simply executes the ServUO exe via mono. I do not have separate exes for windows or linux.

It also uses screen so I can bring the ServUO console back to the foreground when necessary. It seems to work well for me.
 

TheDoc

Well-Known Member
Jun 16, 2014
287
45
44
Atlanta, Georgia
Shard Name
MAGA
Donate
Donate money to this user
John if you get it working could you post your solution? I'm on Debian as well and every online tutorial has been for a previous release or fails to work.
 

john burns

Well-Known Member
Mar 12, 2014
732
23
48
Michigan, USA
vachiadroylia.dynu.net
Shard Name
Vachia Droylia
Worked at it a little, and got this message...

The unit files have no installation config (WantedBy, RequiredBy, Also, Alias settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl. Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some instance name specified.
Post automatically merged:

Hey Doc, this one is for you, and for all Linux users who would like to get this working.....

AND YES, I GOT IT WORKING.

First create the system file...
sudo nano /etc/systemd/system/servuo.service


Then add the following code, editing for your folder and file paths...
[Unit]
Description=servuo.service
After=network.target

[Timer]
OnStartupSec=15

[Service]
User=root
Type=simple
WorkingDirectory=/root/ServUO #--Edit this path to match your server folder
ExecStart=/usr/bin/mono --server /root/ServUO/ServUO.exe #--Edit this path to match your server exe file path

[Install]
WantedBy=multi-user.target

To start the service, use the following...
sudo systemctl start servuo.service
sudo systemctl enable servuo.service


To stop it, use this code...
sudo systemctl stop servuo.service
sudo systemctl disable servuo.service


To make sure it is running, do this...
sudo systemctl status servuo.service
Post automatically merged:

It seems to ignore the Timer section, so it should be safe to remove that section.
 
Last edited:
  • Like
Reactions: TheDoc

Zavreyon

Gold Donator
Apr 5, 2015
83
26
31
To start the service, use the following...
sudo systemctl start servuo.service
sudo systemctl enable servuo.service


To stop it, use this code...
sudo systemctl stop servuo.service
sudo systemctl disable servuo.service
The enable/disable commands are not necessary for starting/stopping each time. Enabling will mean it will automatically start when the server itself is powered on or restarted and attempt to stop it on a graceful shutdown. Once enabled, you just need "service servuo start/stop/status"


It seems to ignore the Timer section, so it should be safe to remove that section.
I believe the timer is only used when it is started from system startup as outlined above, this way you can intentionally have it wait longer so that it is not competing for resources with the other processes starting on boot.


Some enhancements are below, these requires the use of "screen" utility. Execstart in conjunction with screen allows you to look at the ServUO console from any tty session by typing "screen -r servuo" even though it has been run as a service. Just remember not to "ctrl+c" when done viewing, either close the window or detach (ctrl+a followed by ctrl+d) from the screen

ExecStop in conjunction with screen, also allows automated interactions with a screen via the eval and stuff commands without manually resuming it. When stopping the service, the following example will:
1) broadcast a final warning to players ingame
2) wait 10s
3) save and shutdown
4) wait 5s
5) send a wall command to all active tty sessions that the process has ended


servuo.service:
[Unit]
Description=servuo.service
After=network.target

[Timer]
OnStartupSec=60

[Service]
User=root
Type=simple
ExecStart=/bin/sh -c '/usr/bin/screen -DmS servuo /srv/ServUO-56.1/ServUO.sh'
#ExecReload=/usr/bin/screen -p 0 -S servuo -X eval 'stuff "restart"\\015'
ExecStop=/usr/bin/screen -p 0 -S servuo -X eval 'stuff "bc Server Shutdown Imminent"\\015'
ExecStop=/bin/sleep 25
ExecStop=/usr/bin/screen -p 0 -S servuo -X eval 'stuff "shutdown"\\015'
ExecStop=/bin/sleep 5
ExecStop=/usr/bin/wall "ServUO Process Ended via systemd"

[Install]
WantedBy=multi-user.target
This was tested on Debian 10, Mono 6.0.0.310 preview, and ServUO 56.1
 
  • Like
Reactions: TheDoc

Zavreyon

Gold Donator
Apr 5, 2015
83
26
31
The method I posted will hang if the server is restarted outside of screen or systemd, ie restart command ingame. Since screen was used, this effectively makes the ingame [restart command useless (currently broken on mono anyway due to a bug)

To avoid this, you can have it restart the entire service when it detects the initial execstart process exited improperly by adding the following:

oops:
Restart=on-failure
to the [Service] section.

Be warned, however that this will also restart the service after a crash, and if the initial condition causing the crash persists, it wont stop restarting the process until manual intervention to stop it, so I would only use this on production and not when testing or adding new systems/making changes frequently.


There's more than likely more elegant ways to do all of this, but I don't know them.
 
  • Like
Reactions: TheDoc