CntoDev / arma-startup-scripts

A script and some config files to easily get setup with an ARMA 3 server
0 stars 1 forks source link

Add optional restart-on-crash functionality #7

Open freghar opened 3 years ago

freghar commented 3 years ago

Not needed right now, but putting it up here to not forget.

(If possible) keep track of the started HC processes in some variable(s) - I think modern Windows uses PIDs too, so that could work.

If opted-in (via a config variable), start the actual server exe in foreground (or otherwise wait for it to finish). When it finishes, kill off any HCs spawned earlier (ideally by PIDs to not interfere with other arma3server.exe instances running, alternatively by process name if not possible otherwise), then sleep for 60 seconds and loop back, starting all HCs and the server.

The reason for the kill is a case where one or more HCs crash - this allows anybody to do #shutdown to repair the server setup. The 60 second sleep is to prevent 100% CPU infinite loops in case of other issues (permission denied when starting the exe, the exe finishing immediately after startup, etc.).

And ideal solution would be to watch/restart each process individually, but I imagine that would be a PITA to implement.

Didr commented 3 years ago

Note to self: Start-Process with the -PassThru parameter creates a process object.