script systemd auto restart on crash

This commit is contained in:
yusing
2024-03-29 21:43:43 +00:00
parent 662190e09e
commit a0be1f11d3
4 changed files with 22 additions and 7 deletions

View File

@@ -175,3 +175,8 @@ var logLevel = func() logrus.Level {
}
return logrus.GetLevel()
}()
var isRunningAsService = func() bool {
v := os.Getenv("IS_SYSTEMD")
return v == "1"
}()

View File

@@ -19,12 +19,16 @@ func main() {
args := getArgs()
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
DisableColors: false,
FullTimestamp: true,
TimestampFormat: "01-02 15:04:05",
})
if isRunningAsService {
logrus.SetFormatter(&logrus.JSONFormatter{})
} else {
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
DisableColors: false,
FullTimestamp: true,
TimestampFormat: "01-02 15:04:05",
})
}
if args.Command == CommandReload {
err := utils.reloadServer()