Headless save

Find multiplayer games.
Tools/scripts to run a dedicated server.
Post Reply
bruteman
Inserter
Inserter
Posts: 43
Joined: Thu Jan 23, 2014 2:51 pm
Contact:

Headless save

Post by bruteman »

Hey running the Headless on our VPS running good one instance where the server left the game so auto save etc stopped working.

Anyway the server is auto saving to _autosave 1-3 .zip so if you close the server to restart or it crashes as above do you always have to manually rename the _autosave files? as the server never seems to save to the main .zip file (in my case SERVER.zip)

or did i do something wrong in the setup?

batch file calling the server...

start Factorio.exe --start-server SERVER.zip --autosave-interval 10 --latency 12
Image

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: Headless save

Post by Oxyd »

When the server receives SIGINT (press Control-C in the console window, I believe this should work on Windows as well), it will save to the file you loaded from and quit. If it crashes or you kill it in some forceful way, it obviously won't save anything.

You can also run /c game.server_save() from the game console (from any connected peer) to tell the server to save now to the file you loaded. (You can also run game.server_save('filename') if you want to save to some other file.)

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: Headless save

Post by Bisa »

The way I've opted to solve this in my init script for linux is basically before starting the server I check the last modified save in the saves dir and make a copy of this to my --start-server save, in your case that would be pseudo code:

find last modified save
copy last modified save to SERVER.zip
start server
Hosting a factorio server? Take a look at this || init script ||.

ibsteveog
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Dec 04, 2013 4:53 am
Contact:

Re: Headless save

Post by ibsteveog »

Oxyd wrote:When the server receives SIGINT (press Control-C in the console window, I believe this should work on Windows as well), it will save to the file you loaded from and quit. If it crashes or you kill it in some forceful way, it obviously won't save anything.

You can also run /c game.server_save() from the game console (from any connected peer) to tell the server to save now to the file you loaded. (You can also run game.server_save('filename') if you want to save to some other file.)
I run a headleess windows server (12.10) and Ctrl+C to kill the server does not trigger a save to the main file.

Like others, I have to go find the last autosave, accept the fact that it's going to be a bit of a rollback, and move that autosave into place.

2disbetter
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Dec 26, 2015 8:02 pm
Contact:

Re: Headless save

Post by 2disbetter »

Oxyd wrote:When the server receives SIGINT (press Control-C in the console window, I believe this should work on Windows as well), it will save to the file you loaded from and quit. If it crashes or you kill it in some forceful way, it obviously won't save anything.

You can also run /c game.server_save() from the game console (from any connected peer) to tell the server to save now to the file you loaded. (You can also run game.server_save('filename') if you want to save to some other file.)
I'm getting access denied when I attempt this. Is there a new method the server function is being called as a result of a code base change?

2d

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: Headless save

Post by Oxyd »

2disbetter wrote:
Oxyd wrote:When the server receives SIGINT (press Control-C in the console window, I believe this should work on Windows as well), it will save to the file you loaded from and quit. If it crashes or you kill it in some forceful way, it obviously won't save anything.

You can also run /c game.server_save() from the game console (from any connected peer) to tell the server to save now to the file you loaded. (You can also run game.server_save('filename') if you want to save to some other file.)
I'm getting access denied when I attempt this. Is there a new method the server function is being called as a result of a code base change?

2d
No, there isn't.

Which of the two ways are you attempting? And what error message exactly do you get? Are you sure Factorio has write access to the save file's location?

Klynn
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Mar 23, 2016 11:08 pm
Contact:

Re: Headless save

Post by Klynn »

I was wondering if anyone knew a way to have a Windows or Linux shutdown tell the server to exit gracefully? I'm currently running a Windows VM for the server and it's a real pain every time Windows Updates or something else (like my rebooting the hypervisor) reboots the machine and the save doesn't get updated so I have to manually grab an autosave. I'm willing to switch to a CentOS server, and it seems like there's an init script that'll handle grabbing an autosave automatically, but it would still be nice to not be rolled back to an autosave in the event of a shutdown without terminating the server first.

I can't think of any methods on Windows, but I'm a real rookie with Linux so I don't even know where to start on that one.

Is this possible?

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: Headless save

Post by Bisa »

Klynn wrote:I was wondering if anyone knew a way to have a Windows or Linux shutdown tell the server to exit gracefully? I'm currently running a Windows VM for the server and it's a real pain every time Windows Updates or something else (like my rebooting the hypervisor) reboots the machine and the save doesn't get updated so I have to manually grab an autosave. I'm willing to switch to a CentOS server, and it seems like there's an init script that'll handle grabbing an autosave automatically, but it would still be nice to not be rolled back to an autosave in the event of a shutdown without terminating the server first.

I can't think of any methods on Windows, but I'm a real rookie with Linux so I don't even know where to start on that one.

Is this possible?
sorry for being a bit late to the party - 0.12.31 fixed the graceful shutdown save, simply sending a SIGTERM equivalent on windows will save the map, ie if you gracefully shut down the process it will save to your designated save.zip file
Hosting a factorio server? Take a look at this || init script ||.

Post Reply

Return to “Multiplayer / Dedicated Server”