Jump to content

Impossible to send inputs to the dedicated server (GNU/Linux)


Recommended Posts

Hello, I start my server with this script:

#!/bin/bash

cluster_name="whatever" # Cluster's directory name

dontstarve_dir="$HOME/.klei/DoNotStarveTogether"
install_dir="$dontstarve_dir/.dontstarvetogether_dedicated_server"

function fail()
{
        echo Error: "$@" >&2
        exit 1
}

function check_for_file()
{
        if [ ! -e "$1" ]; then
                fail "Missing file: $1"
        fi
}

check_for_file "$dontstarve_dir/$cluster_name/cluster.ini"
check_for_file "$dontstarve_dir/$cluster_name/cluster_token.txt"
check_for_file "$dontstarve_dir/$cluster_name/Master/server.ini"
check_for_file "$dontstarve_dir/$cluster_name/Caves/server.ini"

check_for_file "$install_dir/bin64"

cd "$install_dir/bin64" || fail

run_shared=(./dontstarve_dedicated_server_nullrenderer_x64)
run_shared+=(-console)
run_shared+=(-cluster "$cluster_name")
run_shared+=(-monitor_parent_process $$)

"${run_shared[@]}" -shard Caves  | sed 's/^/Caves:  /' &
"${run_shared[@]}" -shard Master | sed 's/^/Master: /'

Which is basically the recommended Klei's starting script file: https://accounts.klei.com/assets/gamesetup/linux/run_dedicated_servers.sh

Once I launch the ./run_dedicated_servers.sh , whatever input I enter is ignored. I tried with c_announce("test") and c_shutdown(), I'm pretty sure nothing works.

Does anyone else have this issue ?

Thanks

This is happening because the script is running the dst server as a sub process, and all of your input is being directed to bash, not dst. If you want to write to DST instead, you either need to set up a pipe or simply exec dst rather than call it.

22 hours ago, chaosmonkey said:

This is happening because the script is running the dst server as a sub process, and all of your input is being directed to bash, not dst. If you want to write to DST instead, you either need to set up a pipe or simply exec dst rather than call it.

Yes I already thought that was the problem so I made some tests about it.

Using the exec prefix on the last line (right behind ""${run_shared[@]}" -shard Master" ) doesn't fix the issue (my inputs get ignored the same).

Sending the commands directly to the "dontstarve_dedicated_server_nullrenderer_x64" process' STDIN with some `echo "c_announce('test')" > /proc/PID/fd/0` doesn't work either (tried with both the Caves and Master shards).

I failed to set up a mkfifo, I don't know how to do to make it work...

 

You could try running the DST Server(s) in screen sessions like this:

screen -S DSTMaster DST_MasterServer_Launch
screen -S DSTCaves DST_CavesServer_Launch

And then pass your comands to the screen sessions using

screen -S DSTMaster -X YourCommand $'ls -l\n'
screen -S DSTCaves -X YourCommand $'ls -l\n'

For a Shutdown it would look like this for example (I think):

screen -S DSTMaster -X c_shutdown() $'ls -l\n'
screen -S DSTCaves -X c_shutdown() $'ls -l\n'

 

 

Then again, the DST servers should receive the commands from the parent session thanks to the -monitor_parent_process $$ parameter. I could be wrong though...

11 hours ago, Daniel86268 said:

You could try running the DST Server(s) in screen sessions like this:

screen -S DSTMaster DST_MasterServer_Launch
screen -S DSTCaves DST_CavesServer_Launch

And then pass your comands to the screen sessions using

screen -S DSTMaster -X YourCommand $'ls -l\n'
screen -S DSTCaves -X YourCommand $'ls -l\n'

For a Shutdown it would look like this for example (I think):

screen -S DSTMaster -X c_shutdown() $'ls -l\n'
screen -S DSTCaves -X c_shutdown() $'ls -l\n'

 

 

Then again, the DST servers should receive the commands from the parent session thanks to the -monitor_parent_process $$ parameter. I could be wrong though...

That doesn't work, in fact I was already using screen, so I tried this first, before anything else. However, my command looked like this

screen -S DST -X stuff "c_announce('test')^M"

(the ^M is to simulate the Enter key, tried with and without)

I also thought the -monitor_parent_process PID could be used to send command, but no success either.

I must be doing something fundamentally wrong if you guys have success with those methods but I don't :/

Personally I usually always just run my DST Servers when I'm playing with friends, so I haven't run into this issue, but this could also be a workaround for you:

Since you are already fiddling with screen, you can just do a

screen -rx

to reattach the screen session to your current console, and put the commands natively in there.

If you have multiple screen sessions you can list the running screen sessions using

screen -ls

and reattach a specific screen session using

screen -r <session ID>

Like this:

grafik.png.fac75cacfc573590958da4834518735a.png

(Screenshot and individual commands taken from here)

 

For automation it would be annoying/unusable, but if you want to manually announce something and/or shut down the server gracefully, this should work for now.

Alright problem solved, I had "console_enabled = false" under "[MISC]" in my "cluster.ini" file. (Yes, I know...) Little did I know the "-console" parameter was actually deprecated. Thanks anyway guys, sorry for the trouble...

And I confirm sending commands to the bash script works (probably thanks to the "-monitor_parent_process"), there is no need to use exec or pipes.

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...