启动 Apache Gobblin 时自定义服务 systemd 出现问题
Issue with custom service systemd when start Apache Gobblin
运行 /opt/gobblin/bin/gobblin-standalone.sh start
直接一切正常,日志中的输出没问题。
运行 它通过 systemd 服务,不起作用。日志中没有任何输出。
[vagrant@localhost ~]$ sudo systemctl start gobblin
[vagrant@localhost ~]$ sudo systemctl status gobblin
● gobblin.service - Gobblin Data Ingestion Framework
Loaded: loaded (/usr/lib/systemd/system/gobblin.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Sun 2019-01-20 16:44:23 UTC; 693ms ago
Docs: https://gobblin.readthedocs.io
Process: 9673 ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop (code=exited, status=1/FAILURE)
Process: 9671 ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start (code=exited, status=1/FAILURE)
Main PID: 9671 (code=exited, status=1/FAILURE)
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service: control process exited, code=exited status=1
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service holdoff time over, scheduling restart.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Stopped Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: start request repeated too quickly for gobblin.service
Jan 20 16:44:23 localhost.localdomain systemd[1]: Failed to start Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
下面/usr/lib/systemd/system/gobblin.service
的代码:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=simple
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
诀窍在于 Type=oneshot
、RemainAfterExit=true
并设置环境:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=oneshot
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre
Environment=GOBBLIN_FWDIR=/opt/gobblin
Environment=GOBBLIN_JOB_CONFIG_DIR=/etc/gobblin
Environment=GOBBLIN_WORK_DIR=/var/lib/gobblin
Environment=GOBBLIN_LOG_DIR=/var/log/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
运行 /opt/gobblin/bin/gobblin-standalone.sh start
直接一切正常,日志中的输出没问题。
运行 它通过 systemd 服务,不起作用。日志中没有任何输出。
[vagrant@localhost ~]$ sudo systemctl start gobblin
[vagrant@localhost ~]$ sudo systemctl status gobblin
● gobblin.service - Gobblin Data Ingestion Framework
Loaded: loaded (/usr/lib/systemd/system/gobblin.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Sun 2019-01-20 16:44:23 UTC; 693ms ago
Docs: https://gobblin.readthedocs.io
Process: 9673 ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop (code=exited, status=1/FAILURE)
Process: 9671 ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start (code=exited, status=1/FAILURE)
Main PID: 9671 (code=exited, status=1/FAILURE)
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service: control process exited, code=exited status=1
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service holdoff time over, scheduling restart.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Stopped Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: start request repeated too quickly for gobblin.service
Jan 20 16:44:23 localhost.localdomain systemd[1]: Failed to start Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
下面/usr/lib/systemd/system/gobblin.service
的代码:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=simple
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
诀窍在于 Type=oneshot
、RemainAfterExit=true
并设置环境:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=oneshot
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre
Environment=GOBBLIN_FWDIR=/opt/gobblin
Environment=GOBBLIN_JOB_CONFIG_DIR=/etc/gobblin
Environment=GOBBLIN_WORK_DIR=/var/lib/gobblin
Environment=GOBBLIN_LOG_DIR=/var/log/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
RemainAfterExit=true
[Install]
WantedBy=multi-user.target