mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
script systemd auto restart on crash
This commit is contained in:
parent
662190e09e
commit
a0be1f11d3
4 changed files with 22 additions and 7 deletions
|
@ -22,6 +22,8 @@
|
|||
|
||||
3. Start editing config files in `http://<ip>:8080`
|
||||
|
||||
4. Check logs / status with `systemctl status go-proxy`
|
||||
|
||||
## Setup (alternative method)
|
||||
|
||||
1. Download the latest release and extract somewhere
|
||||
|
|
|
@ -91,11 +91,15 @@ mkdir -p /etc/systemd/system
|
|||
cat <<EOF > /etc/systemd/system/go-proxy.service
|
||||
[Unit]
|
||||
Description=go-proxy reverse proxy
|
||||
After=network.target
|
||||
After=network-online.target
|
||||
Wants=network-online.target systemd-networkd-wait-online.service
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=${APP_ROOT}/bin/go-proxy
|
||||
WorkingDirectory=${APP_ROOT}
|
||||
Environment="IS_SYSTEMD=1"
|
||||
Restart=on-failure
|
||||
RestartSec=1s
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
|
|
@ -175,3 +175,8 @@ var logLevel = func() logrus.Level {
|
|||
}
|
||||
return logrus.GetLevel()
|
||||
}()
|
||||
|
||||
var isRunningAsService = func() bool {
|
||||
v := os.Getenv("IS_SYSTEMD")
|
||||
return v == "1"
|
||||
}()
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue