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 fileboy init
cat filegirl.yaml cat filegirl.yaml
fileboy exec fileboy exec
fileboy deamon fileboy daemon
ls -al .fileboy.pid ls -al .fileboy.pid
ps aux | grep fileboy ps aux | grep fileboy
fileboy stop fileboy stop

View File

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

View File

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

View File

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

View File

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

2
raw.go
View File

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