gofmt daemon

pull/3/head
Simon Let 7 years ago
parent 3b90a42240
commit bf9167e96a
  1. 55
      daemon/resh-daemon.go

@ -3,17 +3,17 @@ package main
import (
"encoding/json"
//"flag"
"log"
"github.com/BurntSushi/toml"
common "github.com/curusarn/resh/common"
"io/ioutil"
"path/filepath"
"log"
"net/http"
"os"
"os/exec"
"os/user"
"path/filepath"
"strconv"
"strings"
"net/http"
common "github.com/curusarn/resh/common"
"github.com/BurntSushi/toml"
)
func main() {
@ -24,7 +24,7 @@ func main() {
outputPath := filepath.Join(dir, ".resh/history.json")
logPath := filepath.Join(dir, ".resh/daemon.log")
f, err := os.OpenFile(logPath, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0644)
f, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Fatal("Error opening file:", err)
}
@ -114,7 +114,7 @@ func (h *recordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func runServer(port int, outputPath string) {
http.HandleFunc("/status", statusHandler)
http.Handle("/record", &recordHandler{OutputPath: outputPath})
http.ListenAndServe(":" + strconv.Itoa(port) , nil)
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}
func killDaemon(pidfile string) error {
@ -140,7 +140,7 @@ func isDaemonRunning(port int) (bool, error) {
url := "http://localhost:" + strconv.Itoa(port) + "/status"
resp, err := http.Get(url)
if err != nil {
log.Println("Error while checking daemon status - " +
log.Println("Error while checking daemon status - "+
"it's probably not running!", err)
return false, err
}
@ -148,24 +148,23 @@ func isDaemonRunning(port int) (bool, error) {
return true, nil
//body, err := ioutil.ReadAll(resp.Body)
// dat, err := ioutil.ReadFile(pidfile)
// if err != nil {
// log.Println("Reading pid file failed", err)
// return false, err
// }
// log.Print(string(dat))
// pid, err := strconv.ParseInt(string(dat), 10, 64)
// if err != nil {
// log.Fatal(err)
// }
// process, err := os.FindProcess(int(pid))
// if err != nil {
// log.Printf("Failed to find process: %s\n", err)
// return false, err
// } else {
// err := process.Signal(syscall.Signal(0))
// log.Printf("process.Signal on pid %d returned: %v\n", pid, err)
// }
// return true, nil
// dat, err := ioutil.ReadFile(pidfile)
// if err != nil {
// log.Println("Reading pid file failed", err)
// return false, err
// }
// log.Print(string(dat))
// pid, err := strconv.ParseInt(string(dat), 10, 64)
// if err != nil {
// log.Fatal(err)
// }
// process, err := os.FindProcess(int(pid))
// if err != nil {
// log.Printf("Failed to find process: %s\n", err)
// return false, err
// } else {
// err := process.Signal(syscall.Signal(0))
// log.Printf("process.Signal on pid %d returned: %v\n", pid, err)
// }
// return true, nil
}

Loading…
Cancel
Save