update
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ func Daemon() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
logs.Info(sillyGirl.Get("name", "傻妞") + "以静默形式运行")
|
logs.Info(sillyGirl.Get("name", "傻妞") + "以静默形式运行")
|
||||||
os.WriteFile(pidf, []byte(fmt.Sprintf("%d", proc.Process.Pid)), 0o644)
|
WriteToFile(pidf, (fmt.Sprintf("%d", proc.Process.Pid)))
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -251,7 +250,7 @@ Alias=sillyGirl.service`
|
|||||||
s.Reply(data)
|
s.Reply(data)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
os.WriteFile("/usr/lib/systemd/system/sillyGirl.service", []byte(service), 0o644)
|
WriteToFile("/usr/lib/systemd/system/sillyGirl.service", (service))
|
||||||
exec.Command("systemctl", "disable", string(sillyGirl)).Output()
|
exec.Command("systemctl", "disable", string(sillyGirl)).Output()
|
||||||
exec.Command("systemctl", "enable", string(sillyGirl)).Output()
|
exec.Command("systemctl", "enable", string(sillyGirl)).Output()
|
||||||
return "电脑重启后生效。"
|
return "电脑重启后生效。"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func WriteToFile(fileName string, content string) error {
|
||||||
|
f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("file create failed. err: " + err.Error())
|
||||||
|
} else {
|
||||||
|
n, _ := f.Seek(0, os.SEEK_END)
|
||||||
|
_, err = f.WriteAt([]byte(content), n)
|
||||||
|
defer f.Close()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user