Fix duplicate saving on quit

Slight refactor to split server stop and close functions
	Quit function explicitly sends SIGTERM
	SIGTERM doesn't trigger an os.Exit

	Bonus: Properly save the world on spawning the rover
This commit is contained in:
Marc Di Luzio 2020-06-07 18:06:34 +01:00
parent 141827fa57
commit 8586bdabd7
6 changed files with 28 additions and 13 deletions

View file

@ -129,6 +129,9 @@ func HandleSpawn(s *Server, vars map[string]string, b io.ReadCloser, w io.Writer
} else if attribs, rover, err := s.SpawnRoverForAccount(id); err != nil {
response.Error = err.Error()
} else if err := s.SaveWorld(); err != nil {
response.Error = fmt.Sprintf("Internal server error when saving world: %s", err)
} else {
fmt.Printf("New rover spawned\taccount:%s\trover:%s\tattributes:%+v\n", id, rover, attribs)