你好,我想创建 systemctl 服务来 tun flink 本地服务器。
我可以直接从/bin/start-local.sh
但是当我使用这个服务定义时。
[Unit]
Description=Apache Flink
Documentation=http://flink.apache.org/
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
User=beam1
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
ExecStart=/opt/flink-1.3.2/bin/start-local.sh
ExecStop=-/opt/flink-1.3.2/bin/stop-local.sh
Restart=always
[Install]
WantedBy=multi-user.target
我收到错误,我的服务防御出了什么问题?
Oct 17 04:41:57 beam1 stop-local.sh[3997]: No jobmanager daemon (pid: 3995) is running anymore on beam1.
Oct 17 04:41:57 beam1 systemd[1]: flink.service: Service hold-off time over, scheduling restart.
Oct 17 04:41:57 beam1 systemd[1]: Stopped Apache Flink.
Oct 17 04:41:57 beam1 systemd[1]: Started Apache Flink.
Oct 17 04:41:57 beam1 start-local.sh[4411]: Starting jobmanager daemon on host beam1.
Oct 17 04:41:57 beam1 stop-local.sh[4817]: No jobmanager daemon (pid: 4814) is running anymore on beam1.
Oct 17 04:41:58 beam1 systemd[1]: flink.service: Service hold-off time over, scheduling restart.
Oct 17 04:41:58 beam1 systemd[1]: Stopped Apache Flink.
Oct 17 04:41:58 beam1 systemd[1]: flink.service: Start request repeated too quickly.
Oct 17 04:41:58 beam1 systemd[1]: Failed to start Apache Flink.
答案1
是的!使用其他类型:)
Type=forking
系统男人页面说:
如果设置为 forking,则预计使用 ExecStart= 配置的进程将调用 fork() 作为其启动的一部分。当启动完成并且所有通信通道都建立后,父进程预计将退出。子进程继续作为主服务进程运行,当父进程退出时,服务管理器会认为该单元已启动。这是传统 UNIX 服务的行为。如果使用此设置,建议同时使用PIDFile=选项,以便systemd能够可靠地识别服务的主进程。一旦父进程退出,systemd 将继续启动后续单元。