systemd在Ubuntu上启动后立即停止OrientDB 16.04

问题描述:

我试图在Ubuntu 16.04 LTS上使OrientDB作为守护进程运行(启动时启用)。问题是,系统似乎在我告诉它开始后立即调用stop。我有这个systemd服务文件完全一样OrientDB文档中建议:systemd在Ubuntu上启动后立即停止OrientDB 16.04

[Unit] 
Description=OrientDB Server 
After=network.target 
After=syslog.target 

[Install] 
WantedBy=multi-user.target 

[Service] 
Type=forking 
ExecStart=$ORIENTDB_HOME/bin/orientdb.sh start 
ExecStop=$ORIENTDB_HOME/bin/orientdb.sh stop 
ExecStatus=$ORIENTDB_HOME/bin/orientdb.sh status 

orientdb.log:

  .           
      .`  `         
      ,  `:.         
     `,` ,:`         
     .,. :,,          
     .,, ,,,          
    . .,.::::: ````         :::::::::  ::::::::: 
    ,` .::,,,,::.,,,,,,`;;      .: :::::::::: ::: ::: 
    `,. ::,,,,,,,:.,,.` `      .: :::  ::: :::  ::: 
    ,,:,:,,,,,,,,::. `  `   ``  .: :::  ::: :::  ::: 
     ,,:.,,,,,,,,,: `::, ,, ::,::` : :,::` :::: :::  ::: ::: ::: 
     ,:,,,,,,,,,,::,: ,, :. : :: : .: :::  ::: :::::::  
     :,,,,,,,,,,:,:: ,, :  : :  : .: :::  ::: ::::::::: 
    `  :,,,,,,,,,,:,::, ,, .:::::::: :  : .: :::  ::: :::  ::: 
    `,...,,:,,,,,,,,,: .:,. ,, ,,   :  : .: :::  ::: :::  ::: 
    .,,,,::,,,,,,,: `: , ,, :  ` :  : .: :::  ::: :::  ::: 
     ...,::,,,,::.. `: .,, :, : :  : .: ::::::::::: :::  ::: 
      ,::::,,,. `: ,, ::::: :  : .: :::::::::  :::::::::: 
      ,,:` `,,.         
      ,,, .,`         
     ,,.  `,           GRAPH DATABASE 
     ``  `.               
       ``           orientdb.com 
       `          
pid file detected, killing process 

系统日志:

Jul 28 18:56:34 ubuntu systemd[1]: Starting OrientDB Server... 
Jul 28 18:56:34 ubuntu orientdb.sh[17487]: Starting OrientDB server daemon... 
Jul 28 18:56:34 ubuntu systemd[1]: Created slice User Slice of orientdb. 
Jul 28 18:56:34 ubuntu systemd[1]: Starting User Manager for UID 999... 
Jul 28 18:56:34 ubuntu systemd[1]: Started Session c5 of user orientdb. 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Timers. 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Paths. 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Sockets. 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Basic System. 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Default. 
Jul 28 18:56:34 ubuntu systemd[17497]: Startup finished in 23ms. 
Jul 28 18:56:34 ubuntu systemd[1]: Started User Manager for UID 999. 
Jul 28 18:56:34 ubuntu orientdb.sh[17508]: Stopping OrientDB server daemon... 
Jul 28 18:56:34 ubuntu systemd[1]: Started Session c6 of user orientdb. 
Jul 28 18:56:34 ubuntu systemd[1]: Started OrientDB Server. 
Jul 28 18:56:34 ubuntu systemd[1]: Stopping User Manager for UID 999... 
Jul 28 18:56:34 ubuntu systemd[17497]: Reached target Shutdown. 
Jul 28 18:56:34 ubuntu systemd[17497]: Starting Exit the Session... 
Jul 28 18:56:34 ubuntu systemd[17497]: Stopped target Default. 
Jul 28 18:56:34 ubuntu systemd[17497]: Stopped target Basic System. 
Jul 28 18:56:34 ubuntu systemd[17497]: Stopped target Timers. 
Jul 28 18:56:34 ubuntu systemd[17497]: Stopped target Paths. 
Jul 28 18:56:34 ubuntu systemd[17497]: Stopped target Sockets. 
Jul 28 18:56:34 ubuntu systemd[17497]: Received SIGRTMIN+24 from PID 17536 (kill). 
Jul 28 18:56:34 ubuntu systemd[1]: Stopped User Manager for UID 999. 
Jul 28 18:56:34 ubuntu systemd[1]: Removed slice User Slice of orientdb. 

任何想法?

+0

你是否按照此链接指南(http://orientdb.com/docs/2.1/Unix-Service.html)? – lsavio

+0

是的,这就是问题所在。我跟着文档(见上面的脚本),它不工作:)。 – austinsmorris

+0

好的,你可以在Github上打开一个问题吗?..谢谢。 – lsavio

只要在systemd服务单元中包装自定义初始化脚本(orientdb.sh ,server.sh,shutdown.sh),您将遇到奇怪且难以调试的问题。

相反,您应该阅读这些脚本,了解他们如何启动OrientDB并仅重现服务单元中的必需内容。

我添加了一个用户&组orientdb到系统和下面systemd脚本中使用(假设orientdb安装在的/ opt/orientdb):

[Unit] 
Description=OrientDB Server 
After=network.target 
After=syslog.target 

[Install] 
WantedBy=multi-user.target 

[Service] 
User=orientdb 
Group=orientdb 
ExecStart=/opt/orientdb/bin/server.sh 
ExecStop=/opt/orientdb/bin/shutdown.sh 
ExecReload=/bin/kill -HUP $MAINPID 

如果你运行的服务器和关闭窗口,服务器将被关闭。将它与NOHUP(server.sh)一起使用,如果关闭该窗口,它将继续运行。

我有同样的问题,运气好的话

我有同样的问题,用了OpenSuse 42.1飞跃和OrientDB 2.2.7。 罗伯托的答案解决了它。见the issue on GitHub