Jump to content

(SOLVED) [Ubuntu 22.04] Unable to control session using /usr/bin/screen properly (Setting up systemctl)


ClumsyBear

Recommended Posts

Hello,

 

I am trying to set up a dedicated server that is running on a fresh install of Ubuntu 22.04 Server.  I have followed the Dedicated Server docs up to the point of being able to get a server running successfully.  However, I have been running into issues in getting the server to start under systemctl.
 

NOTE: I configured the sever settings on my main PC through the game client, and then pushed the config files over to the machine and dropped them in my user server directory:

/home/pzuser/Zomboid/Server

 

Initialized/ran the server as "pzuser" (the same user that logs into to steam as anonymous user, downloads and verifies app, and does not have "sudo" privileges).

su - pzuser
/opt/pzserver/start-server.sh -servername ZRespawn2

 

After running this command, the server started and I was prompted to enter an admin password & confirm.  After start I was able to confirm my friends were able to join. I can execute "save" and "exit" in the console and see the log output:

CONSOLE1 (pzuser):
/opt/pzserver/start-server.sh --servername ZRespawn2
..
##########
Server Steam ID xxxxxxxxxxxxxxxxx
##########
LOG  : Multiplayer , 1662673224384> 18,915,354> [MPStatistics] mem usage notification threshold=16,320,875,520
LOG  : General     , 1662673225433> 18,916,403> 1662673225433> znet: OnPolicyResponse
LOG  : General     , 1662673225433> 18,916,403> 1662673225433> znet: Zomboid Server is VAC Secure
save
LOG  : General     , 1662673238903> 18,929,873> command entered via server console (System.in): "save"
LOG  : General     , 1662673239013> 18,929,983> World saved
LOG  : General     , 1662673239057> 18,930,027> SaveAll took 31.509791 ms
LOG  : General     , 1662673239059> 18,930,029> reanimate: saved 0 zombies
LOG  : General     , 1662673239067> 18,930,037> Saving GlobalModData
LOG  : General     , 1662673239067> 18,930,037> Saving finish
LOG  : General     , 1662673239067> 18,930,037> Saving took 41.734015 ms
quit
LOG  : General     , 1662673244096> 18,935,066> command entered via server console (System.in): "quit"
DEBUG: Multiplayer , 1662673244133> 18,935,103> QuitCommand.Command                 > cmd="quit" user="admin" role="32" unknown connection"
LOG  : Multiplayer , 1662673244133> 18,935,103>         java.base/java.lang.Thread.getStackTrace(Unknown Source)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.debug.DebugLogStream.printStackTrace(DebugLogStream.java:159)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.debug.DebugLogStream.printStackTrace(DebugLogStream.java:146)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.network.ServerMap.QueueQuit(ServerMap.java:91)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.commands.serverCommands.QuitCommand.Command(QuitCommand.java:29)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.commands.CommandBase.Execute(CommandBase.java:131)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.network.GameServer.handleServerCommand(GameServer.java:1167)
LOG  : Multiplayer , 1662673244134> 18,935,104>         zombie.network.GameServer.main(GameServer.java:901)
LOG  : General     , 1662673244134> 18,935,104> Quit
LOG  : General     , 1662673244254> 18,935,224> SaveAll took 27.668544 ms
LOG  : General     , 1662673244255> 18,935,225> reanimate: saved 0 zombies
LOG  : General     , 1662673244261> 18,935,231> Saving GlobalModData
LOG  : General     , 1662673244261> 18,935,231> Saving finish
LOG  : General     , 1662673244262> 18,935,232> Saving took 35.018751 ms
LOG  : General     , 1662673250828> 18,941,798> waiting for UdpEngine thread termination
LOG  : General     , 1662673250839> 18,941,809> 1662673250839> znet: Java_zombie_core_raknet_RakNetPeerInterface_Shutdown
LOG  : General     , 1662673250839> 18,941,809> 1662673250839> znet: Shutting down Steam Game Server
LOG  : General     , 1662673252212> 18,943,182> 1662673252212> znet: Java_zombie_core_znet_SteamUtils_n_1Shutdown

 

I am now trying to set up "screen" (for use with systemctl), which I found here.  First, I was just trying to test out the screen commands.  When running the shell with the following commands, I do not see any output when sending the "save" command to the screen console.  When using "quit" A short stack track is printed out but no messages regarding an actual save:
 

CONSOLE1 (pzuser):
screen -DmS pzserver /opt/pzserver/start-server.sh

CONSOLE2 (pzusr):
screen -S pzserver -X save
screen -S pzserver -X quit

CONSOLE3 (pzuser):
tail -f /home/pzuser/Zomboid/server-console.txt
..
##########
Server Steam ID xxxxxxxxxxxxxxxxx
##########.
[08-09-22 21:53:59.814] LOG  : Multiplayer , 1662674039814> 19,730,784> [MPStatistics] mem usage notification threshold=16,320,875,520.
[08-09-22 21:54:00.800] LOG  : General     , 1662674040800> 19,731,770> 1662674040800> znet: OnPolicyResponse.
[08-09-22 21:54:00.801] LOG  : General     , 1662674040801> 19,731,771> 1662674040801> znet: Zomboid Server is VAC Secure.
[08-09-22 21:56:38.673] ERROR: General     , 1662674198673> 19,889,643> java.io.IOException: Input/output error.
[08-09-22 21:56:38.673] ERROR: General     , 1662674198673> 19,889,643>         at java.base/java.io.FileInputStream.readBytes(Native Method).
[08-09-22 21:56:38.673] ERROR: General     , 1662674198673> 19,889,643>         at java.base/java.io.FileInputStream.read(Unknown Source).
[08-09-22 21:56:38.673] ERROR: General     , 1662674198673> 19,889,643>         at java.base/java.io.BufferedInputStream.read1(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198673> 19,889,643>         at java.base/java.io.BufferedInputStream.read(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/sun.nio.cs.StreamDecoder.readBytes(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/sun.nio.cs.StreamDecoder.read(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/java.io.InputStreamReader.read(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/java.io.BufferedReader.fill(Unknown Source).
[08-09-22 21:56:38.674] ERROR: General     , 1662674198674> 19,889,644>         at java.base/java.io.BufferedReader.readLine(Unknown Source).

 

I also tried setting PATH and LD_LIBRARY path similar to the forum post I linked above, but in doing so it doesn't even start/output logs:

CONSOLE1 (pzuser):
export PATH=/opt/pzserver/jre64/bin:$PATH
export LD_LIBRARY_PATH=/opt/pzserver/linux64:/opt/pzserver/natives:/opt/pzserver:/opt/pzserver/jre64/lib/amd64:$LD_LIBRARY_PATH
screen -DmS pzserver /opt/pzserver/ProjectZomboid64 -adminpassword ${mypass}

CONSOLE2 (pzuser):
tail -f /home/pzuser/Server/console-output.txt
{NOTHING}

 

Sorry for the long post I wanted to try and get any necessary info in the post.  Any help/ideas on how to resolve this or what I could be doing wrong?

 

 

Edited by ClumsyBear
Link to comment
Share on other sites

Sorry, I missed that the commands in the to control terminal were for rcon.  Was able to get it working with the following pzserver.service file

[Unit]
Description=Project Zomboid Server

[Service]
Type=simple
User=pzuser
WorkingDirectory=/opt/pzserver
ExecStart=/usr/bin/screen -DmS pzserver /opt/pzserver/start-server.sh -servername ZRespawn2
ExecStop=/usr/bin/rcon -H localhost -p {rcon_port} -P {rcon_pass} save
ExecStop=/usr/bin/rcon -H localhost -p {rcon_port} -P {rcon_pass} quit
ExecStop=/usr/bin/screen -S pzserver -X quit

[Install]
WantedBy=multi-user.target
Alias=pzserver

 

Edited by ClumsyBear
Link to comment
Share on other sites

  • ClumsyBear changed the title to (SOLVED) [Ubuntu 22.04] Unable to control session using /usr/bin/screen properly (Setting up systemctl)

For future reference, if you wish to do this with screen use "screen -S pzserver -X stuff "Save^M"" and Quit^M respectively.

I'll admit it's slightly janky as there is no sanity check but right now you were telling screen to quit, not pzomboid. Stuff lets you pass commands as if you were typing in the terminal.

 

(the ^M is emulating an enter)

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...