1
0

Merge pull request from Psychomantis71/master

Autostart feature
This commit is contained in:
knoxfighter 2020-08-18 19:04:48 +02:00 committed by GitHub
commit 881cf32ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

@ -66,7 +66,10 @@ Usage of ./factorio-server-manager:
Path to the glibc ld.so file (default "/opt/glibc-2.18/lib/ld-2.18.so")
-glibc-lib-loc
Path to the glibc lib folder (default "/opt/glibc-2.18/lib")
-autostart
Autostarts Factorio Server when FSM is starting. Default false [true/false]
(If no IP and/or port provided at startup, it will bind the factorio server to all interfaces
and set the server port to the default 34197, always loads latest save)
Example:
./factorio-server-manager --dir /home/user/.factorio --host 10.0.0.1

@ -43,6 +43,27 @@ func randomPort() int {
return rand.Intn(45000-40000) + 40000
}
func autostart() {
var err error
if FactorioServ.BindIP == "" {
FactorioServ.BindIP = "0.0.0.0"
}
if FactorioServ.Port == 0 {
FactorioServ.Port = 34197
}
FactorioServ.Savefile = "Load Latest"
err = FactorioServ.Run()
if err != nil {
log.Printf("Error starting Factorio server: %+v", err)
return
}
}
func initFactorio() (f *FactorioServer, err error) {
f = new(FactorioServer)
f.Settings = make(map[string]interface{})
@ -161,6 +182,10 @@ func initFactorio() (f *FactorioServer, err error) {
}
}
if config.autostart == "true" {
go autostart()
}
return
}

@ -38,6 +38,7 @@ type Config struct {
glibcCustom string
glibcLocation string
glibcLibLoc string
autostart string
}
var (
@ -79,8 +80,10 @@ func parseFlags() {
glibcCustom := flag.String("glibc-custom", "false", "By default false, if custom glibc is required set this to true and add glibc-loc and glibc-lib-loc parameters")
glibcLocation := flag.String("glibc-loc", "/opt/glibc-2.18/lib/ld-2.18.so", "Location glibc ld.so file if needed (ex. /opt/glibc-2.18/lib/ld-2.18.so)")
glibcLibLoc := flag.String("glibc-lib-loc", "/opt/glibc-2.18/lib", "Location of glibc lib folder (ex. /opt/glibc-2.18/lib)")
autostart := flag.String("autostart", "false", "Autostart factorio server on bootup of FSM, default false [true/false]")
flag.Parse()
config.autostart = *autostart
config.glibcCustom = *glibcCustom
config.glibcLocation = *glibcLocation
config.glibcLibLoc = *glibcLibLoc