mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 04:53:50 +00:00
custom npc systemd service script, increase open files limit
This commit is contained in:
parent
c7a5388cfd
commit
099d3fcf2c
@ -35,6 +35,31 @@ var (
|
|||||||
debug = flag.Bool("debug", true, "npc debug")
|
debug = flag.Bool("debug", true, "npc debug")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const systemdScript = `[Unit]
|
||||||
|
Description={{.Description}}
|
||||||
|
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
||||||
|
{{range $i, $dep := .Dependencies}}
|
||||||
|
{{$dep}} {{end}}
|
||||||
|
[Service]
|
||||||
|
LimitNOFILE=65536
|
||||||
|
StartLimitInterval=5
|
||||||
|
StartLimitBurst=10
|
||||||
|
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
||||||
|
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
|
||||||
|
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
|
||||||
|
{{if .UserName}}User={{.UserName}}{{end}}
|
||||||
|
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
|
||||||
|
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
|
||||||
|
{{if and .LogOutput .HasOutputFileSupport -}}
|
||||||
|
StandardOutput=file:/var/log/{{.Name}}.out
|
||||||
|
StandardError=file:/var/log/{{.Name}}.err
|
||||||
|
{{- end}}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=120
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
logs.Reset()
|
logs.Reset()
|
||||||
@ -54,8 +79,6 @@ func main() {
|
|||||||
|
|
||||||
// init service
|
// init service
|
||||||
options := make(service.KeyValue)
|
options := make(service.KeyValue)
|
||||||
options["Restart"] = "on-success"
|
|
||||||
options["SuccessExitStatus"] = "1 2 8 SIGKILL"
|
|
||||||
svcConfig := &service.Config{
|
svcConfig := &service.Config{
|
||||||
Name: "Npc",
|
Name: "Npc",
|
||||||
DisplayName: "nps内网穿透客户端",
|
DisplayName: "nps内网穿透客户端",
|
||||||
@ -66,6 +89,7 @@ func main() {
|
|||||||
svcConfig.Dependencies = []string{
|
svcConfig.Dependencies = []string{
|
||||||
"Requires=network.target",
|
"Requires=network.target",
|
||||||
"After=network-online.target syslog.target"}
|
"After=network-online.target syslog.target"}
|
||||||
|
svcConfig.Option["SystemdScript"] = systemdScript
|
||||||
}
|
}
|
||||||
for _, v := range os.Args[1:] {
|
for _, v := range os.Args[1:] {
|
||||||
switch v {
|
switch v {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user