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