Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master server as service on Linux - Automatic Restart After Crash #200

Open
itech4ever opened this issue May 30, 2018 · 2 comments
Open

Comments

@itech4ever
Copy link

Dear all, I am now trying to deploy the server to the cloud but realised that I am not sure how to make the server as a service and how to restart it autonomically if there is any bug that crashes the server.

Would there be any advice from you guys? Thanks!

@felladrin
Copy link

Hi there.

I'm still reading about MasterServer before using it, but I've seen your question, and here is an idea.

How about registering a cron job to call this script below, like every three minutes?
(Considering you have the files described on Tutorial: Building to Linux VPS)

check_game_server.sh (which should be in the same folder as the GameServer.x86_64):

#!/bin/bash
ps auxw | grep GameServer.x86_64 | grep -v grep > /dev/null
if [ $? != 0 ]; then
    cd $(dirname $(which $0) )
    ./GameServer.x86_64
fi

If you have MasterAndSpawner.x86_64, you can duplicate this .sh file, just changing the filename on the script, and register another cron job.

Probably there's a better way to achieve this, but this is what came to mind for now. Used to work for me two years ago, on another project.

Check this topic to get more ideas for bash scripts.

@itech4ever
Copy link
Author

itech4ever commented Jun 1, 2018

@felladrin thanks a lot! I also thought about this but was worried about the availability of the service during the 3 minutes windows, that is, if the server somehow crashes, it is possible that it can only be restarted in 3 minutes or within another time window defined in cron jobs.

Taking it further, will the masterserver have something there that can be a "gate server" that acts as a package dispatcher? Which means, I can start two servers in parallel: one is called "Online Server", another can be called as "Standby Server".

The gate server distributes the received packages from clients to the two server always, but once the Online Server dies, it will make the Standby Server as the Online Server and creates another server as a Standby server.

Of course, the complexity of the gate server should be minimised to make sure it can be always online and/or some other measures can be taken to make it alive all the time.

Of course, I will try your method for now but any discussions around this "gate server" would be highly welcomed! Thanks a ton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants