Work on deb and rpm packages, both seem to work now, #1476
This commit is contained in:
@@ -5,8 +5,12 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/Unknwon/macaron"
|
||||
"github.com/codegangsta/cli"
|
||||
@@ -68,6 +72,7 @@ func mapStatic(m *macaron.Macaron, dir string, prefix string) {
|
||||
|
||||
func runWeb(c *cli.Context) {
|
||||
initRuntime(c)
|
||||
writePIDFile(c)
|
||||
|
||||
social.NewOAuthService()
|
||||
eventpublisher.Init()
|
||||
@@ -92,3 +97,22 @@ func runWeb(c *cli.Context) {
|
||||
log.Fatal(4, "Fail to start server: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func writePIDFile(c *cli.Context) {
|
||||
path := c.GlobalString("pidfile")
|
||||
if path == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure the required directory structure exists.
|
||||
err := os.MkdirAll(filepath.Dir(path), 0700)
|
||||
if err != nil {
|
||||
log.Fatal(3, "Failed to verify pid directory", err)
|
||||
}
|
||||
|
||||
// Retrieve the PID and write it.
|
||||
pid := strconv.Itoa(os.Getpid())
|
||||
if err := ioutil.WriteFile(path, []byte(pid), 0644); err != nil {
|
||||
log.Fatal(3, "Failed to write pidfile", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user