Make the server program a little smart; detect the directory to determine PID and logfile names
This commit is contained in:
parent
74deb5f9a1
commit
46b14665bf
19
main.go
19
main.go
|
@ -80,6 +80,7 @@ var (
|
||||||
|
|
||||||
const DEBUG = false
|
const DEBUG = false
|
||||||
|
|
||||||
|
const HOME_DIR = "/home/kelvin/"
|
||||||
const DOMAIN_NAME = "threefortiethofonehamster.com"
|
const DOMAIN_NAME = "threefortiethofonehamster.com"
|
||||||
|
|
||||||
const HTML_HEADER = `<!doctype html5>
|
const HTML_HEADER = `<!doctype html5>
|
||||||
|
@ -171,25 +172,15 @@ func main() {
|
||||||
daemon.AddCommand(daemon.StringFlag(signal, "stop"), syscall.SIGTERM, termHandler)
|
daemon.AddCommand(daemon.StringFlag(signal, "stop"), syscall.SIGTERM, termHandler)
|
||||||
daemon.AddCommand(daemon.StringFlag(signal, "reload"), syscall.SIGHUP, reloadHandler)
|
daemon.AddCommand(daemon.StringFlag(signal, "reload"), syscall.SIGHUP, reloadHandler)
|
||||||
|
|
||||||
|
execName := os.Args[0]
|
||||||
cntxt := &daemon.Context{
|
cntxt := &daemon.Context{
|
||||||
PidFileName: "/tmp/main-server-pid",
|
PidFileName: "/tmp/" + execName + "-pid",
|
||||||
PidFilePerm: 0644,
|
PidFilePerm: 0644,
|
||||||
LogFileName: "/tmp/main-server-log",
|
LogFileName: "/tmp/" + execName + "-log",
|
||||||
LogFilePerm: 0640,
|
LogFilePerm: 0640,
|
||||||
WorkDir: "/home/kelvin/main-server/",
|
WorkDir: HOME_DIR + execName + "/",
|
||||||
Umask: 027,
|
Umask: 027,
|
||||||
}
|
}
|
||||||
if *devmode {
|
|
||||||
cntxt = &daemon.Context{
|
|
||||||
PidFileName: "/tmp/dev-server-pid",
|
|
||||||
PidFilePerm: 0644,
|
|
||||||
LogFileName: "/tmp/dev-server-log",
|
|
||||||
LogFilePerm: 0640,
|
|
||||||
WorkDir: "/home/kelvin/dev-server/",
|
|
||||||
Umask: 027,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if DEBUG {
|
if DEBUG {
|
||||||
cntxt.WorkDir = "."
|
cntxt.WorkDir = "."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue