简体   繁体   English

无法在Ubuntu中将Jetty9作为服务安装

[英]Unable to install Jetty9 as a service in Ubuntu

I've followed the docs in order to install Jetty9 as a service but whenever I run 为了将Jetty9作为服务安装,我一直关注文档 ,但是无论何时运行

service jetty start

It would fail with no messages, my JETTY_HOME is /opt/jetty9 , contains the home distribution for version 9.4.14. 它将失败且没有任何消息,我的JETTY_HOME/opt/jetty9 ,其中包含版本9.4.14的主发行版。 I've also created my JETTY_BASE at /usr/share/jetty9 with my webapp and modules. 我还使用Webapp和模块在/usr/share/jetty9处创建了JETTY_BASE

Both Jetty Home and Base are owned by the user jetty . 用户码头拥有Jetty Home和Base。 I've then symlinked to my init.d folder as: 然后,将我的init.d文件夹符号链接为:

ln -s /opt/jetty9/bin/jetty.sh /etc/init.d/jetty

Then I created a /etc/default/jetty file with the following content: 然后,我创建了一个/etc/default/jetty文件,其内容如下:

# change to 1 to prevent Jetty from starting
NO_START=0

# change to 'no' or uncomment to use the default setting in /etc/default/rcS
VERBOSE=yes

# Run Jetty as this user ID (default: jetty)
# Set this to an empty string to prevent Jetty from starting automatically
JETTY_USER=jetty

# The home directory of the Java Runtime Environment (JRE). You need at least
# Java 6. If JAVA_HOME is not set, some common directories for OpenJDK and
# the Oracle JDK are tried.
#JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

# Extra options to pass to the JVM
#JAVA_OPTIONS="-Xmx256m -Djava.awt.headless=true"

# Timeout in seconds for the shutdown of all webapps
#JETTY_SHUTDOWN=30

# Additional arguments to pass to Jetty
#JETTY_ARGS=

# Jetty uses a directory to store temporary files like unpacked webapps
TMPDIR=/opt/jetty9/tmp
JETTY_HOME=/opt/jetty9
JETTY_BASE=/usr/share/jetty9

# Default for number of days to keep old log files in /var/log/jetty9/
#LOGFILE_DAYS=14

# If you run Jetty on port numbers that are all higher than 1023, then you # do not need authbind. It is used for binding Jetty to lower port numbers.
# (yes/no, default: no)
#AUTHBIND=yes
JETTY_HOST=0.0.0.0

If I start Jetty using java -jar $JETTY_HOME/start.jar in my base folder it would work with no problem. 如果我在基本文件夹中使用java -jar $JETTY_HOME/start.jar启动Jetty,那将毫无问题。 Also, if I run 另外,如果我跑步

service jetty supervise

It would also run with no issues, but when I call start it fails with: 它也可以正常运行,但是当我调用start它失败并显示:

root@app:/usr/share/jetty9# service jetty start
Job for jetty.service failed because the control process exited with error code.
See "systemctl status jetty.service" and "journalctl -xe" for details.
root@app:/usr/share/jetty9# service jetty status
● jetty.service - LSB: Jetty start script.
   Loaded: loaded (/etc/init.d/jetty; generated)
   Active: failed (Result: exit-code) since Mon 2018-12-03 15:05:26 UTC; 14s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 21162 ExecStop=/etc/init.d/jetty stop (code=exited, status=0/SUCCESS)
  Process: 21202 ExecStart=/etc/init.d/jetty start (code=exited, status=1/FAILURE)

Dec 03 15:05:22 app systemd[1]: Stopped LSB: Jetty start script..
Dec 03 15:05:22 app systemd[1]: Starting LSB: Jetty start script....
Dec 03 15:05:26 app jetty[21202]: Starting Jetty: FAILED Mon Dec  3 15:05:26 UTC 2018
Dec 03 15:05:26 app systemd[1]: jetty.service: Control process exited, code=exited status=1
Dec 03 15:05:26 app systemd[1]: jetty.service: Failed with result 'exit-code'.
Dec 03 15:05:26 app systemd[1]: Failed to start LSB: Jetty start script..

This is the output of service jetty check : 这是service jetty check的输出:

root@app:/usr/share/jetty9# service jetty check
Jetty NOT running

JAVA                  =  /usr/bin/java
JAVA_OPTIONS          =  -Djetty.home=/opt/jetty9 -Djetty.base=/usr/share/jetty9 -Djava.io.tmpdir=/opt/jetty9/tmp
JETTY_HOME            =  /opt/jetty9
JETTY_BASE            =  /usr/share/jetty9
START_D               =  /usr/share/jetty9/start.d
START_INI             =  /usr/share/jetty9/start.ini
JETTY_START           =  /opt/jetty9/start.jar
JETTY_CONF            =  /opt/jetty9/etc/jetty.conf
JETTY_ARGS            =  jetty.state=/usr/share/jetty9/jetty.state jetty-started.xml
JETTY_RUN             =  /var/run/jetty
JETTY_PID             =  /var/run/jetty/jetty.pid
JETTY_START_LOG       =  /var/run/jetty/jetty-start.log
JETTY_STATE           =  /usr/share/jetty9/jetty.state
JETTY_START_TIMEOUT   =  60
RUN_CMD               =  /usr/bin/java -Djetty.home=/opt/jetty9 -Djetty.base=/usr/share/jetty9 -Djava.io.tmpdir=/opt/jetty9/tmp -jar /opt/jetty9/start.jar jetty.state=/usr/share/jetty9/jetty.state jetty-started.xml

Any ideas? 有任何想法吗?

UPDATE 更新

Changing the user in /etc/default/jetty to root would solve the issue, but this is not a solution, isn't it? /etc/default/jetty的用户更改为root可以解决此问题,但这不是解决方案,不是吗?

# Run Jetty as this user ID (default: jetty)
# Set this to an empty string to prevent Jetty from starting automatically
JETTY_USER=root

I finally got this working, the jetty user should have permissions to the following folders and /usr/sbin/nologin as shell as described here . 我终于得到了这个工作, 码头用户应该有权限下列文件夹和/usr/sbin/nologin作为外壳所描述这里

JETTY_HOME
JETTY_BASE
/var/run/jetty   <-- couldn't find a reference to this folder in the docs

And add the following to your /etc/default/jetty : 并将以下内容添加到您的/etc/default/jetty

JETTY_SHELL=/bin/sh
JETTY_LOGS=/usr/share/jetty9/logs
JETTY_START_LOG=/usr/share/jetty9/logs/jetty-start-log.log

Also you should double check that there are no remaining log files owned by other user than jetty in your folders. 另外,您应该仔细检查文件夹中是否有除jetty以外的其他用户所有的剩余日志文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM