mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-18 04:59:02 +02:00
Merge branch 'patch-12' into patch-13
This commit is contained in:
commit
41d5307375
@ -6,8 +6,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type FactorioServer struct {
|
||||
@ -119,26 +119,27 @@ func (f *FactorioServer) Run() error {
|
||||
}
|
||||
|
||||
func (f *FactorioServer) Stop() error {
|
||||
err := f.Cmd.Process.Signal(os.Interrupt)
|
||||
|
||||
// SIGINT is not implemented on Windows.
|
||||
if err != nil && err == syscall.EWINDOWS {
|
||||
// TODO: Shutdown Factorio on Windows so the map can be saved.
|
||||
err = f.Cmd.Process.Signal(os.Kill)
|
||||
// TODO: Find an alternative to os.Kill on Windows. os.Interupt
|
||||
// is not implemented. Maps will not be saved.
|
||||
if runtime.GOOS == "windows" {
|
||||
err := f.Cmd.Process.Signal(os.Kill)
|
||||
if err != nil {
|
||||
log.Printf("Error sending SIGKILLL to Factorio process: %s", err)
|
||||
return err
|
||||
} else {
|
||||
f.Running = false
|
||||
log.Println("Sent SIGKILL to Factorio process. Factorio forced to exit.")
|
||||
}
|
||||
} else if err != nil {
|
||||
log.Printf("Error sending SIGINT to Factorio process: %s", err)
|
||||
return err
|
||||
} else {
|
||||
log.Printf("Sent SIGINT to Factorio process. Factorio shutting down...")
|
||||
err := f.Cmd.Process.Signal(os.Interrupt)
|
||||
if err != nil {
|
||||
log.Printf("Error sending SIGINT to Factorio process: %s", err)
|
||||
return err
|
||||
} else {
|
||||
f.Running = false
|
||||
log.Printf("Sent SIGINT to Factorio process. Factorio shutting down...")
|
||||
}
|
||||
}
|
||||
|
||||
f.Running = false
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user