Kill命令在服务文件中不起作用

时间:2019-04-02 05:20:09

标签: service kill

我有一个通过服务文件运行的go版本。该服务文件具有以下内容:

[Unit]
Description=testApp

[Service]
Type=simple
Restart=always
RestartSec=5
WorkingDirectory= /home/user
ExecStart=/home/user/testApp

PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/testApp
ExecStartPre=/bin/chown syslog:adm /var/log/testApp
ExecStartPre=/bin/chmod 755 /var/log/testApp
ExecStartPre=/bin/kill -l SIGKILL
ExecStartPost=/bin/bash -c 'curl "IP:PORT/API-URL"'
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=testApp

[Install]
WantedBy=multi-user.target

从上述服务中,我想在启动该服务之前终止所有正在运行的进程。为此,我已经使用

ExecStartPre=/bin/kill -l SIGKILL

终止所有进程后,我希望启动服务,并且在启动服务后应执行api。

现在,每当我重新启动服务时,都会出现以下错误:

Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: set the cluster version to 3.1 from store
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: panic: listen tcp 0.0.0.0:2379: bind: address already in use
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: goroutine 1 [running]:
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/pkg/localkube.createListenersOrPanic(0xc4203a3e80, 0x1, 0x1, 0x0, 0x3d817e0, 0xc420460620)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/pkg/localkube/etcd.go:143 +0x2aa
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/pkg/localkube.(*EtcdServer).Start(0xc420215170)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/pkg/localkube/etcd.go:100 +0xa4
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/cmd/localkube/cmd.SetupServer(0xc4206ea9a0)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/cmd/localkube/cmd/start.go:98 +0x28e
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/cmd/localkube/cmd.StartLocalkube()
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/cmd/localkube/cmd/start.go:51 +0x6e
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/cmd/localkube/cmd.glob..func1(0x8cebc80, 0xc4206b3980, 0x0, 0x4)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/cmd/localkube/cmd/root.go:31 +0x20
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).execute(0x8cebc80, 0xc420010100, 0x4, 0x4, 0x8cebc80, 0xc420010100)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:603 +0x22b
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x8cebc80, 0x49e4275, 0x2e, 0xc4206ea9f8)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:689 +0x339
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).Execute(0x8cebc80, 0x0, 0x0)
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:648 +0x2b
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]: main.main()
Apr 01 05:07:30 ip-10-0-30-136 localkube[30427]:         /go/src/k8s.io/minikube/cmd/localkube/main.go:32 +0x5f
Apr 01 05:07:30 ip-10-0-30-136 systemd[1]: localkube.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 01 05:07:30 ip-10-0-30-136 systemd[1]: Failed to start Localkube.
-- Subject: Unit localkube.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit localkube.service has failed.
--
-- The result is failed.
Apr 01 05:07:30 ip-10-0-30-136 systemd[1]: localkube.service: Unit entered failed state.
Apr 01 05:07:30 ip-10-0-30-136 systemd[1]: localkube.service: Failed with result 'exit-code'.

任何人都可以解释一下这里发生了什么。我无法得到问题及其解决方案。

谢谢!

0 个答案:

没有答案