1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-07-04 12:03:43 +02:00

src/server.go: Use pid package and write pid file.

This commit is contained in:
Henrik Hautakoski 2020-06-11 19:01:06 +02:00
parent 060535f595
commit e0c7cfcc62

View file

@ -6,6 +6,7 @@ import (
"strings" "strings"
"strconv" "strconv"
"./log" "./log"
"./pid"
"./haproxy" "./haproxy"
"./eosapi" "./eosapi"
"github.com/firstrow/tcp_server" "github.com/firstrow/tcp_server"
@ -116,8 +117,14 @@ func main() {
getopt.FlagLong(&pidFile, "pid", 'p', "Path to pid file", "file") getopt.FlagLong(&pidFile, "pid", 'p', "Path to pid file", "file")
getopt.Parse() getopt.Parse()
log.Info("Process is starting with PID: %d", pid.Get())
if len(pidFile) > 0 { if len(pidFile) > 0 {
log.Info("Writing pidfile: %s", pidFile) log.Info("Writing pidfile: %s", pidFile)
_, err := pid.Save(pidFile)
if err != nil {
log.Error("Failed to write pidfile: %v", err)
}
} }
server := tcp_server.New(argv_listen_addr()) server := tcp_server.New(argv_listen_addr())