Server Down when close console

Jenkings
Member
 
Posts: 12
Joined: Thu May 17, 2012 09:02

Server Down when close console

by Jenkings » Sun Nov 17, 2013 12:35

Hello.

I have a little problem.

I have compiled and installed the minetest game / server on VPS.
I connect to VPS by SSH console and run server by typing ./minetestserver and the server starts,but problem is, when i close the SSH connection, the minetestserver stops :/

Can you help me please ?
Sorry for my bad English.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Nov 17, 2013 12:55

Use screen
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

Jenkings
Member
 
Posts: 12
Joined: Thu May 17, 2012 09:02

by Jenkings » Sun Nov 17, 2013 13:01

There is nothing to screen :/

Simply when i close the SSH session, the server is down too, and the log file ends with standard message which is logged before it falls
Sorry for my bad English.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Nov 17, 2013 13:23

I mean this
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

Jenkings
Member
 
Posts: 12
Joined: Thu May 17, 2012 09:02

by Jenkings » Sun Nov 17, 2013 13:42

Thanks a lot. It helped me ;)
Sorry for my bad English.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Sun Nov 17, 2013 19:13

Or start it with ./minetestserver &
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Nov 17, 2013 19:37

BrandonReese wrote:Or start it with ./minetestserver &

It is way harder to kill one specific minetestserver instance when you do it like this.
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
lightonflux
Member
 
Posts: 384
Joined: Mon Nov 11, 2013 07:22
In-game: lof

by lightonflux » Sun Nov 17, 2013 23:15

Use tmux, it is so much better than screen! /flamewar_ends

tmux has some great features (screen might has - i never really used it)

Start tmux:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
tmux


"action key" in tmux:

ctrl+b

to list all "windows"

ctrl+b+l

get help: ctrl+b+?

go to "window" $number

ctrl+b+$number


i think you get the idea.

To logout of tmux like every where else:

ctrl+b+d

because ctrl+d will exit a shell

then tmux runs in the background, when you log in again just type
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
tmux a
(for append) and you will find your tmux session like it was before.

Also cool stuff: ctrl+b+" and ctrl+b+% you change between the sides with ctrl+b+arrow
 

User avatar
lightonflux
Member
 
Posts: 384
Joined: Mon Nov 11, 2013 07:22
In-game: lof

by lightonflux » Sun Nov 17, 2013 23:51

I see nobody explained what happened. I try.

On UNIX/Linux processes are spawned in a tree.

At the root there is a process called "init" which is spawns every other process. init has the first PID (process ID) so 1 (or 0 on some systems).

So somewhere in the tree there is a process called sshd, which is the deamon (therefore the d in sshd) which provides the ssh server. When a user logs in via ssh sshd will spawn a process (ssh login shell) for the user. Now when the user starts a program like it will be spawned by the ssh login shell.

So minetest is a child of your ssh shell. When you exit the shell it will be exited (closed/terminated), therefore all childs (like the minecraft server) die.

Let's look at the simplified tree:

init
└─ sshd
└─ ssh session
└── login shell
└── minetest


So when you leave the session all three processes will die.

That's it.

There are several ways to "disconnect" a child process from its parent (it will get another parent - remember there is always init). Like

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
command &
command & disown
nohup command


When you use screen/tmux your process (minetest server) will be a child of screen/tmux, which is not a child of sshd or it's sessions for obvious reasons.

If you want to look at the tree, just use

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
pstree


Hope this explanation helps.

lightonflux
 

Jenkings
Member
 
Posts: 12
Joined: Thu May 17, 2012 09:02

by Jenkings » Mon Nov 18, 2013 20:45

Thanks for all replies, I am a bit smarter now.

Now i understand this problem and know how it works ;)
Sorry for my bad English.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 8 guests

cron