Soft Shutdown Script

#1

Ever wanted to restart all servers in your game without losing a bunch of players? I’ve written a script that does this. It works by hooking into game:BindToClose() and teleporting all players into a reserved server, which basically serves as a lobby. When a server spawns up, if it’s a reserved server (and not a VIP server), it will automatically wait a few seconds and then teleport players back into the main place.

Note that if you don’t wait before teleporting everyone back into the main game, the game will tend to match-make each player into their own server, which is why I added some wait() statements in between teleporting each player.

I’ve only tested this on small games (300 players, 10 servers) but I am curious how well it works on larger games. Please make pull requests if you figure out any improvements.

Script source:

142 Likes
Advanced Shutdown Script
Best method of shutting down a game
How do you shutdown without having players go back and press play?
Allow us to phase out old servers by preventing new players from joining
Game Development Resources [MEGA THREAD]
What is the best way to update your games?
Uniform server version number in configure place
Force-reboot a server
Is there any other way to improve my DataStore more?
Server shutdowns triggered by a proxy server using HTTPService - is this a bad idea?
#2

Thank you! I will have to try this out. If only we could link our script sources to github repositories…

4 Likes
#3

This is great! I’ll definitely be using this in the future.

1 Like
#4

This is the most clever use of reserved servers I have seen. I will definitely try to implement a modified version for Ultimate Boxing (mainly the message).

4 Likes
#5

Thank you so much for this! This’ll be pretty neat if any of my games actually get popular and I need to release an urgent update without losing all of my players!

1 Like
#6

This is a great use of reserved servers as now I won’t have to worry about loosing players! :grinning::grinning:

#7

I made an identical system a few months back for my game but had to rip it out due to some issues.

The main issue was that no matter how long I waited it seemed some servers would never die fast enough so teleporting back would sometimes end up in old servers or fail attempting to join a dead server. I was doing everything like kicking any pkayers attempting to join etc. But no luck. It was a mess.

Since then teleportService and servers migt have become more reliable and it might be time for me to reimplement but im unsure,

EDIT: Read the code properly and realised it activated when the server was shutdown from the site anyways which is a smart alternative to what I was doing. I’m not sure if this would’ve solved my servers shutting down fast enough issue but it looks like it might have.

#8

That’s the plus side of using reserved servers, no one will accidentally get placed into the ‘lobby’ servers.

Worth noting that there was also a bug that was only recently fixed where game.OnClose would kick out all players before you had the chance to teleport them out.

#9

Cool, I might use this for my game.

#10

Already implemented in my game and works like a charm. It’s almost fun for me to shut down servers now, just to watch the servers disappear and return within seconds!

2 Likes
#11

Oh, no what I meant was:

I teleported all the players to reserved servers and let them wait there for a bit, then when I teleported them back sometimes some of the old serverrs would still be alive and they’d end up in those.

#12

This may sound silly but is there a way to shutdown all servers via chat commands? Sometimes im testing a game and i say Shutdown to close a single one since my game isn’t very big.

#13

This is sweet! I will use it later on!

#14

For anyone interested: Just shut down my servers with 1.4k CCU and everything turned out smoothly – only lost about 200 players. Datastores still working smoothly, no data lost. Love this script!

3 Likes
#15

Now implemented and ready for the next Ultimate Boxing update. :grin:

10 Likes
#16

Added to my game, with about 1k concurrent users, 90 servers. Will let you know how it goes.

5 Likes
#17

That’s so simple, yet such a good solution for this. Innovation at its finest :slight_smile:

4 Likes
#18

This sounds incredibly useful, I can’t wait to test it!

1 Like
#19

Has anyone run into this yet with this model?

#20

I think he was talking about his old system of rebooting servers. Shouldn’t happen with soft shutdown.