remove PID file hack - twitch-go - twitch.tv web application in Go
(HTM) git clone git://git.codemadness.org/twitch-go
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 3fdbc7ac62c19ffaa21116b92f964d288a09dafe
(DIR) parent 8aeb80d8a391df192f097c6feca57de5e25cd31f
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 12 Jun 2016 16:22:46 +0200
remove PID file hack
Diffstat:
M main.go | 37 -------------------------------
1 file changed, 0 insertions(+), 37 deletions(-)
---
(DIR) diff --git a/main.go b/main.go
@@ -11,10 +11,8 @@ import (
"net"
"net/http"
"os"
- "os/signal"
"path/filepath"
"strings"
- "syscall"
"time"
)
@@ -142,10 +140,8 @@ func main() {
var config_templatethemedir string = "templates/themes/default/"
var config_templatepagedir string = "templates/pages/"
var config_staticcontentdir string = "static/"
- var config_pidfile string
flag.StringVar(&config_datadir, "d", "", "Chdir to data directory")
- flag.StringVar(&config_pidfile, "f", "", "PID file")
flag.StringVar(&config_addr, "l", "127.0.0.1:8080", "listen address")
flag.UintVar(&config_chmod, "m", 0755, "Permission for unix domain socket")
flag.StringVar(&config_addrtype, "t", "tcp4", `listen type: "tcp", "tcp4", "tcp6", "unix" or "unixpacket"`)
@@ -176,38 +172,6 @@ func main() {
}
}
- // Write PID to pid file.
- if config_pidfile != "" {
- pid := os.Getpid()
- if err = ioutil.WriteFile(config_pidfile, []byte(fmt.Sprintf("%d", pid)), 0644); err != nil {
- log.Fatalln(err)
- }
- }
-
- // Delete PID file on exit.
- Cleaned := false
- Cleanup := func() {
- if Cleaned == true {
- return
- }
- Cleaned = true
- if config_pidfile != "" {
- os.Remove(config_pidfile)
- }
- }
-
- // Setup cleanup handler.
- c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt)
- go func() {
- for sig := range c {
- if sig == syscall.SIGINT {
- Cleanup()
- os.Exit(1)
- }
- }
- }()
-
templates = NewTemplates()
// Parse templates and keep in-memory.
err = templates.LoadPages(config_templatepagedir)
@@ -241,5 +205,4 @@ func main() {
MaxHeaderBytes: 1 << 20,
}
s.Serve(l)
- Cleanup()
}