Work on deb and rpm packages, both seem to work now, #1476

This commit is contained in:
Torkel Ödegaard
2015-03-03 17:14:58 +01:00
parent 59da4a0b3b
commit 0db55b6194
10 changed files with 201 additions and 120 deletions
+24
View File
@@ -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)
}
}