A more robust server starting mechanism (#463)

now lf will start the server in the current directory (which will then
Chdir to the user's home directory) to ensure it is always starting as
the user intended.
This commit is contained in:
Provessor 2020-09-09 21:08:52 +10:00 committed by GitHub
parent ec512dfe31
commit 61442f8880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,6 @@ func exportEnvVars() {
func startServer() { func startServer() {
cmd := detachedCommand(os.Args[0], "-server") cmd := detachedCommand(os.Args[0], "-server")
cmd.Dir = gUser.HomeDir
if err := cmd.Start(); err != nil { if err := cmd.Start(); err != nil {
log.Printf("starting server: %s", err) log.Printf("starting server: %s", err)
} }
@ -157,6 +156,7 @@ func main() {
log.Fatalf("remote command: %s", err) log.Fatalf("remote command: %s", err)
} }
case *serverMode: case *serverMode:
os.Chdir(gUser.HomeDir)
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username)) gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
serve() serve()
default: default: