GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.34k stars 821 forks source link

jq: error (at <stdin>:0): Cannot iterate over null (null) #3006

Closed Tiscan closed 4 years ago

Tiscan commented 4 years ago

User Story

When running ./sdtdserver I get the error messages:

jq: error (at :0): Cannot iterate over null (null) jq: error (at :0): Cannot iterate over null (null)

Before the command executes.

Also the ./sdtserver monitor command fails as the port gets listed as 2690026900269052701527020 even though the port is configured and running as 26900.

I searched the jq error here and found one reference from a but it just said that it was set to be fixed many versions back. Also found a reference to the port issue but there was no resolution on that one.

Basic info

Further Information

Completely fresh OS & LGSM install as of a couple of days ago.

To Reproduce

Run any ./sdtdserver , monitor command errors via ./sdtdserver monitor

Expected behaviour

Successful execution of command without errors, monitor option detecting correct port.

I am attaching the results of a details command below as you can see both the jq error and the port incorrect. Happy to provide other logs / etc if someone can point me to what they need.

sdtd@jinnix:~$ ./sdtdserver details
jq: error (at <stdin>:0): Cannot iterate over null (null)
jq: error (at <stdin>:0): Cannot iterate over null (null)

Distro Details
=================================
Distro:    Ubuntu 20.04.1 LTS
Arch:      x86_64
Kernel:    5.4.0-42-generic
Hostname:  jinnix
Uptime:    1d, 2h, 12m
tmux:      tmux 3.0a
glibc:     2.31

Server Resource
=================================
CPU
Model:      Intel(R) Xeon(R) CPU           L5640  @ 2.27GHz
Cores:      24
Frequency:  1596.243MHz
Avg Load:   0.14, 0.19, 0.13

Memory
Mem:       total  used   free   cached  available
Physical:  71GB   3.1GB  68GB   11GB    68GB
Swap:      8.0GB  0B     8.0GB

Storage
Filesystem:  /dev/sdb
Total:       11T
Used:        23G
Available:   7.3T

Network
Interface:    eno1
Link Speed:   1000Mb/s
IP:           [REMOVED]
Internet IP:  [REMOVED]

Game Server Resource Usage
=================================
CPU Used:  48.5%
Mem Used:  3.5%   2588MB

Storage
Total:        9.7G
Serverfiles:  9.4G

7 Days To Die Server Details
=================================
Server name:      [REMOVED]
App ID:           294420
Server IP:        [REMOVED]:2690026900269052701527020
Internet IP:      [REMOVED]:2690026900269052701527020
Server password:  [REMOVED]
Maxplayers:       20
Game mode:        GameModeSurvival
Game world:       East Soasa County
Master server:    false
Status:           ONLINE

sdtdserver Script Details
=================================
Script name:            sdtdserver
LinuxGSM version:       v20.4.1
glibc required:         2.15
Discord alert:          off
Slack alert:            off
Email alert:            off
Pushbullet alert:       off
IFTTT alert:            off
Mailgun (email) alert:  off
Pushover alert:         off
Telegram alert:         off
Update on start:        off
User:                   sdtd
Location:               /data/sdtd
Config file:            /data/sdtd/serverfiles/sdtdserver.xml

Backups
=================================
No Backups created

Command-line Parameters
=================================
./7DaysToDieServer.x86_64 -logfile /data/sdtd/log/server/output_log__2020-08-21__00-21-25.txt -quit -batchmode -nographics -dedicated -configfile=/data/sdtd/serverfiles/sdtdserver.xml

Ports
=================================
Change ports by editing the parameters in:
/data/sdtd/serverfiles/sdtdserver.xml

Useful port diagnostic command:
netstat -atunp | grep 7DaysToDie

DESCRIPTION  DIRECTION  PORT                       PROTOCOL
> Game/RCON  INBOUND    2690026900269052701527020  udp
> Query      INBOUND    2690026900269052701527020  udp
> WebAdmin   INBOUND    8080                       tcp
> Telnet     INBOUND    8081                       tcp

[REMOVED] WebAdmin
=================================
WebAdmin enabled:   false
WebAdmin url:       [REMOVED]
WebAdmin password:  [REMOVED]

[REMOVED] Telnet
=================================
Telnet enabled:   true
Telnet address:   [REMOVED]
Telnet password:  [REMOVED]

Status: ONLINE
issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.95. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

sapphirecz commented 4 years ago

I have the same issue with sdtdserver release A19 on Fedora. sdtdserver with the same version of LGSM but release A18.4 (installation was moved from CentOS few weeks ago) is on Fedora without this issue. I probably could test it on CentOS if necessary.

Here is postdetails pastebin https://termbin.com/iaug3

pschiffe commented 4 years ago

Hello, I think I found the issue. There are numbers in the comment on the same line as the port number, see here:

$ grep ServerPort /home/sdtdhost2/serverfiles/sdtdserver.xml
<property name="ServerPort"                 value="26900"/>         <!-- Port you want the server to listen on. Keep it in the ranges 26900 to 26905 or 27015 to 27020 if you want PCs on the same LAN to find it as a LAN server. -->

$ grep ServerPort /home/sdtdhost2/serverfiles/sdtdserver.xml | tr -cd '[:digit:]'
2690026900269052701527020

https://github.com/GameServerManagers/LinuxGSM/blob/7e3df5d43479d3cc9f053688386d8ff8a92c8f80/lgsm/functions/info_config.sh#L125

pschiffe commented 4 years ago

Sorry, wrong line, sdtd is here https://github.com/GameServerManagers/LinuxGSM/blob/7e3df5d43479d3cc9f053688386d8ff8a92c8f80/lgsm/functions/info_config.sh#L1213

Tiscan commented 4 years ago

Can confirm this is the issue.

I moved the comment to a line on it's own in sdtdserver.xml and neither error occurs anymore.

pschiffe commented 4 years ago

The solution to this problem could be parsing xml files properly. There is an xmlstarlet package available in centos, fedora, debian and ubuntu (these I checked, it's probably elsewhere too), which can be used to extract xml values. For example in this case it looks like this:

$ grep ServerPort /home/sdtdhost2/serverfiles/sdtdserver.xml
    <property name="ServerPort"                 value="26900"/>
$ xmlstarlet sel -t -v '//property[@name="ServerPort"]/@value' /home/sdtdhost2/serverfiles/sdtdserver.xml
26900

The selector there says: give me @value attribute of property with attribute @name == "ServerPort".

Tiscan commented 4 years ago

Also confirmed that xmlstarlet works on my install. However this would add a new dependency to LGSM.

Seems like a good path though as there will bound to be additional instances where digits are outside of the actual XML attribute.

sdtd@jinnix:~$ xmlstarlet sel -t -v '//property[@name="ServerPort"]/@value' sdtdserver.xml
26900
h3o66 commented 4 years ago

Alternative: put a egrep for the value in the original command:

port=$(grep "ServerPort" "${servercfgfullpath}" | egrep -o 'value="([0-9+])"' | tr -cd '[:digit:]')

The problem with a new dependency is here that only a few gameserver will need this.

dgibbs64 commented 4 years ago

@h3o66 this would be the best solution to avoid another dependency. If you are happy too could you do a PR and I will merge

h3o66 commented 4 years ago

@h3o66 this would be the best solution to avoid another dependency. If you are happy too could you do a PR and I will merge

done - see the connected pr

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.