msmhq / msm

An init script for managing Minecraft servers
http://msmhq.com
GNU General Public License v3.0
1.22k stars 225 forks source link

service won't stop -- multiple screens? #257

Open dankegel opened 10 years ago

dankegel commented 10 years ago

When I try to stop, it gets confused and hangs waiting for the server to stop.

This is a problem especially because now "sudo shutdown -r now" hangs!

$ cat /etc/issue Ubuntu 13.10 \n \l

$ msm version Minecraft Server Manager 0.8.16 Beta

$ sudo service msm stop There are several suitable screens on: 12141.msm-towncraft (04/12/2014 09:01:58 AM) (Detached) 11926.msm-towncraft (04/12/2014 09:00:02 AM) (Detached) Use -S to specify a session. Server "towncraft" was running, now stopping: Issued the warning "SERVER SHUTTING DOWN IN 10 SECONDS!" to players. Stopping after 10 seconds. All servers will have been issued the stop command... in 0 second.There are several suitable screens on: 12141.msm-towncraft (04/12/2014 09:01:58 AM) (Detached) 11926.msm-towncraft (04/12/2014 09:00:02 AM) (Detached) Use -S to specify a session. Now. Ensuring server "towncraft" has stopped...

Paaltomo commented 10 years ago

I have also encountered this error. Please help us out.

Tsubashi commented 10 years ago

Try running "screen -wipe" as the msm user.

jdpepperman commented 9 years ago

I'm having the same issue. screen -wipe did not resolve.

M-D-M commented 9 years ago

I used to have this issue when I had multiple instances of the same minecraft world running (accidentally) -- jdpepperman, do you have multiple screens as well?

jdpepperman commented 9 years ago

I shouldn't, no. I made sure there weren't any running and even rebooted the machine, but it always hangs after "ensuring server ... has stopped". What's worse is that it seems that once this happens, everything else kind of hangs too. Even commands to the machine itself to shutdown or reboot don't seem to work, and sometimes once they do I have trouble using ssh to get back in again.

M-D-M commented 9 years ago

Do your minecraft worlds launch right after the machine reboots? If so, check how many screens are running right after you log in with something like "ps ax | grep SCREEN" -- if it's more than one, there's something wrong with how the world is launching.

The problem on shutting down is a simpler one -- the terminal window is just not accepting your commands anymore. You could ssh into the machine with a different terminal and shut it down from there.

Pressing "Ctrl-C" at that step doesn't get you back to the prompt?

jdpepperman commented 9 years ago
 1936 ?        Ss     0:00 SCREEN
 2401 pts/1    S+     0:00 grep --color=auto SCREEN

That is the output I get from that command, which looks normal to me.

And yeah I should've mentioned, I pressed Ctrl-C after waiting on the "ensuring server ... has stopped" message for a while before I tried running the reboot command. So it was taking the command and broadcasting that the server is going down for reboot, but then it wouldn't. I could even log in from another terminal for a while after that message was displayed.

(Thanks for looking at this for me by the way.)

renderorange commented 9 years ago

Hello. If that ps output is from after you've started msm, then minecraft isn't starting correctly. That's just showing there is a screen session running, but nothing in the screen session.

You should be getting output like the following when the server is running:

 1440 ?        Ss     0:00 SCREEN -dmS msm-stable java -Xms1024M -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -jar /opt/msm/servers/stable/server.jar nogui
M-D-M commented 9 years ago

Agreed -- there was something wrong with that output.

Could you do "ps faux", just to see what username owns that process?

sebunger commented 8 years ago

Hi There,

Did you ever find out what this is about? Because I'm having a very similar issue: My server appears to start normal, but at some point after that it stops responding to any and all commands directed at the server directly. I have only observed this happening after I had used the console, but I'm not sure that's only when it happens. It only happens occasionally.

So, I ssh onto my server, say sudo msm svr1 console and I can interact with the server, issue whitelist commands, say things to players etc. Then I disconnect via Ctrl-A-D. Sometime later a cron-job issues this command: msm stop; poweroff to shut the server down at the end of the day, but the command hangs. If I repeat it from the command line, it goes through its 'shutting down in 10s' thing and eventually hangs saying "Ensuring svr1 is down" or something like that. If I now connect to the console with sudo msm svr1 console I can see that not only the stop commands but also the backup commands like save off, save on etc are visible on the screen, but there's no response from the actual minecraft server. I can type more commands, but the behaviour is exactly the same as if I typed them into a cat >/dev/null session, i.e. no responses.

If I send the actual java process a TERM signal, the machine finally goes down.

sebunger commented 8 years ago

Ahhh, I just found out how to reproduce this!

If I connect to the console on my server, then simply close my SSH connection from the remote end (rather than detaching via Ctrl-A D) the screen appears to remain attached (probably because the TCP session was idle). At this point, if I SSH back into my server and try to connect to the console again, I get this error:

ubuntu@hostabc:~$ sudo msm svr1 console
There is a screen on:
        3233.msm-svr1  (02/27/2016 11:42:24 AM)        (Attached)
There is no screen to be resumed matching msm-svr1.

Now, if there's some activity in the game (I joined the server), the behaviour changes to the one I've described before. Presumably because the server prints something the local SSH detects that the TCP connection has long since gone and terminates. This detaches the screen, but leaves msm in some funky state. If I now issue the command above again, I get the following:

ubuntu@hostabc:~$ sudo msm svr1 console

This clears the screen and brings up:

......
[11:46:18] [Server thread/INFO]: ***** joined the game
say Hi there
say Anybody there?
[11:48:47] [Server thread/INFO]: ***** lost connection: TextComponent{text='Disconnected', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
[11:48:47] [Server thread/INFO]: ***** left the game
stop
whitelist list
say Hello

As you can see, it connected to the console, but no commands are working. I left the game again while connected to the console, and you can see that the 'left the game' message did come through to the console even while it was in this state.

At this point the only way to stop that server is to send a SIGTERM to the actual java process.

Has anybody got any idea?

Cheers, Seb

sebunger commented 8 years ago

Another update: Ctrl-C in the console in the above state does work and terminates the server. Starting it again via sudo msm svr1 start brings everything back to normal.

sebunger commented 8 years ago

And one more: I just repeated all the steps. It behaved the same up to the point where I joined the game to cause it to detect the dead SSH session. This time at it all went back to normal at this point. I.e. I could connect to the console and all commands worked.

:-(