From 56be65888c7bae971f920be0f802fe51fdd1aec8 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 16 Nov 2019 16:07:54 -0800 Subject: [PATCH] Don't try to truncate a file that doesn't actually exist yet --- server/environment_docker.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/environment_docker.go b/server/environment_docker.go index f4f96f0..84af60e 100644 --- a/server/environment_docker.go +++ b/server/environment_docker.go @@ -167,9 +167,12 @@ func (d *DockerEnvironment) Start() error { } // Truncate the log file so we don't end up outputting a bunch of useless log information - // to the websocket and whatnot. - if err := os.Truncate(c.LogPath, 0); err != nil { - return err + // to the websocket and whatnot. Check first that the path and file exist before trying + // to truncate them. + if _, err := os.Stat(c.LogPath); err == nil { + if err := os.Truncate(c.LogPath, 0); err != nil { + return err + } } // Reset the permissions on files for the server before actually trying