typo deamon->daemon

This commit is contained in:
dengsgo 2020-03-16 11:16:14 +08:00
parent 588af5143f
commit 4f81692954
6 changed files with 19 additions and 15 deletions

View File

@ -39,7 +39,7 @@ jobs:
fileboy init
cat filegirl.yaml
fileboy exec
fileboy deamon
fileboy daemon
ls -al .fileboy.pid
ps aux | grep fileboy
fileboy stop

View File

@ -20,7 +20,7 @@ script:
- fileboy init
- cat filegirl.yaml
- fileboy exec
- fileboy deamon
- fileboy daemon
- ls -al .fileboy.pid
- ps aux | grep fileboy
- fileboy stop

View File

@ -1,5 +1,9 @@
### Release v1.15
2020.03.16
- typo deamon->daemon
2020.03.08
- 优化 指令模式

View File

@ -12,11 +12,11 @@ func getPidFile() string {
return projectFolder + "/.fileboy.pid"
}
func runAsDeamon() (int, error) {
func runAsDaemon() (int, error) {
if runtime.GOOS == "windows" {
logAndExit("daemons mode cannot run on windows.")
}
err := stopDeamon()
err := stopDaemon()
if err != nil {
logAndExit(err)
}
@ -24,22 +24,22 @@ func runAsDeamon() (int, error) {
if err != nil {
logAndExit("cannot found `fileboy` command in the PATH")
}
deamon := exec.Command("fileboy")
deamon.Dir = projectFolder
deamon.Env = os.Environ()
deamon.Stdout = os.Stdout
err = deamon.Start()
daemon := exec.Command("fileboy")
daemon.Dir = projectFolder
daemon.Env = os.Environ()
daemon.Stdout = os.Stdout
err = daemon.Start()
if err != nil {
logAndExit(err)
}
pid := deamon.Process.Pid
pid := daemon.Process.Pid
if pid != 0 {
ioutil.WriteFile(getPidFile(), []byte(strconv.Itoa(pid)), 0644)
}
return pid, nil
}
func stopDeamon() error {
func stopDaemon() error {
bs, err := ioutil.ReadFile(getPidFile())
if err != nil {
return nil

View File

@ -265,8 +265,8 @@ func parseArgs() {
case len(os.Args) > 1:
c := os.Args[1]
switch c {
case "deamon":
pid, err := runAsDeamon()
case "deamon", "daemon":
pid, err := runAsDaemon()
if err != nil {
logAndExit(err)
}
@ -274,7 +274,7 @@ func parseArgs() {
logUInfo("fileboy is ready. the main process will run as a daemons")
return
case "stop":
err := stopDeamon()
err := stopDaemon()
if err != nil {
logAndExit(err)
}

2
raw.go
View File

@ -112,7 +112,7 @@ Usage of fileboy:
初始化 fileboy, 在当前目录生成 filegirl.yaml 配置文件
exec
尝试运行定义的 command 命令
deamon
daemon
读取当前目录下的 filegirl.yaml 配置以守护进程的方式运行在后台
stop
停止守护进程