new conf system start
This commit is contained in:
parent
cf6a9c0a97
commit
105f03bf67
|
@ -29,7 +29,7 @@ func runRun(cmd *warren.Command, args ...string) {
|
|||
return
|
||||
}
|
||||
|
||||
s, err := net.Dial(warren.CmdSockType(), warren.CmdSockAddr())
|
||||
s, err := net.Dial(warren.CmdSockType, warren.CmdSockAddr)
|
||||
if s != nil {
|
||||
defer s.Close()
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func sockCmdHandle(c net.Conn) {
|
|||
|
||||
// determine if warrend is already running
|
||||
func checkRunning() bool {
|
||||
if pfile, err := os.Open(warren.WarrendPidFile()); err == nil {
|
||||
if pfile, err := os.Open(warren.WarrendPidFile); err == nil {
|
||||
// pid file exists
|
||||
var pid int
|
||||
n, err := fmt.Fscanf(pfile, "%d", &pid)
|
||||
|
@ -78,9 +78,9 @@ func checkRunning() bool {
|
|||
|
||||
func initRunning() {
|
||||
// rm old sock
|
||||
os.Remove(warren.CmdSockAddr())
|
||||
os.Remove(warren.CmdSockAddr)
|
||||
// drop down pid
|
||||
pidfile, err := os.Create(warren.WarrendPidFile())
|
||||
pidfile, err := os.Create(warren.WarrendPidFile)
|
||||
if err != nil {
|
||||
log.Fatal("Could not create pidfile: ", warren.WarrendPidFile(), " : ", err)
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func initRunning() {
|
|||
fmt.Fprintf(pidfile, "%d", pid)
|
||||
pidfile.Close()
|
||||
|
||||
cmdSock, err = net.Listen(warren.CmdSockType(), warren.CmdSockAddr())
|
||||
cmdSock, err = net.Listen(warren.CmdSockType, warren.CmdSockAddr)
|
||||
if err != nil {
|
||||
fmt.Println(cmdSock)
|
||||
Shutdown()
|
||||
|
@ -98,7 +98,7 @@ func initRunning() {
|
|||
}
|
||||
|
||||
func Shutdown() {
|
||||
os.Remove(warren.WarrendPidFile())
|
||||
os.Remove(warren.WarrendPidFile)
|
||||
if cmdSock != nil {
|
||||
cmdSock.Close()
|
||||
}
|
||||
|
|
|
@ -10,21 +10,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var cmdSockType string = "unix"
|
||||
var cmdSockAddr string = "/var/run/warrend/warrend.sock"
|
||||
var warrendPidFile string = "/var/run/warrend/warrend.pid"
|
||||
|
||||
func CmdSockType() string {
|
||||
return cmdSockType
|
||||
}
|
||||
|
||||
func CmdSockAddr() string {
|
||||
return cmdSockAddr
|
||||
}
|
||||
|
||||
func WarrendPidFile() string {
|
||||
return warrendPidFile
|
||||
}
|
||||
const CmdSockType string = "unix"
|
||||
const CmdSockAddr string = "/var/run/warrend/warrend.sock"
|
||||
const WarrendPidFile string = "/var/run/warrend/warrend.pid"
|
||||
const WarrendConf string = "/etc/warrend.conf"
|
||||
|
||||
func GitHash() string {
|
||||
hash, err := exec.Command("git", "rev-parse", "HEAD").Output()
|
||||
|
|
Loading…
Reference in New Issue