I am a new user of Jetty, and with only a few months of linux-server 
experience. The goal is to set up the forum software JForum2 as a service.

I can run JForum2 manually from root. But using the same location and 
variables, the following error comes up when running as a service.

root@localhost:/opt/web/jgobase# service jetty start
root@localhost:/opt/web/jgobase# service jetty status
● jetty.service - Jetty
  Loaded: loaded (/etc/systemd/system/jetty.service; enabled; vendor preset: 
enabled)
  Active: failed (Result: exit-code) since Wed 2019-08-07 22:06:31 UTC; 5s ago
 Process: 20059 ExecStart=/usr/bin/java -jar 
/opt/jetty/jetty-distribution-9.4.19.v20190610/start.jar jetty.home=/opt/
Main PID: 20059 (code=exited, status=254)Aug 07 22:06:31 localhost java[20059]: 
        ... 8 more
Aug 07 22:06:31 localhost java[20059]: Caused by: java.io.IOException: Cannot 
write log directory /logs
Aug 07 22:06:31 localhost java[20059]:         at 
org.eclipse.jetty.util.RolloverFileOutputStream.setFile(RolloverFileO
Aug 07 22:06:31 localhost java[20059]:         at 
org.eclipse.jetty.util.RolloverFileOutputStream.<init>(RolloverFileOu
Aug 07 22:06:31 localhost java[20059]:         at 
org.eclipse.jetty.util.RolloverFileOutputStream.<init>(RolloverFileOu
Aug 07 22:06:31 localhost java[20059]:         ... 24 more
Aug 07 22:06:31 localhost java[20059]: Usage: java -jar $JETTY_HOME/start.jar 
[options] [properties] [configs]
Aug 07 22:06:31 localhost java[20059]:        java -jar $JETTY_HOME/start.jar 
--help  # for more information
Aug 07 22:06:31 localhost systemd[1]: jetty.service: Main process exited, 
code=exited, status=254/n/a
Aug 07 22:06:31 localhost systemd[1]: jetty.service: Failed with result 
'exit-code'.
root@localhost:/opt/web/jgobase# service jetty stop[/code]


I am attempting to follow as closely as possible the tutorial at the Jetty site:
https://www.eclipse.org/jetty/documentation/9.4.19.v20190610/startup-unix-service.html


Here is the result of "service jetty check":

root@localhost:~# service jetty check
Jetty NOT running

JAVA                  =  /usr/bin/java
JAVA_OPTIONS          =  
-Djetty.home=/opt/jetty/jetty-distribution-9.4.19.v20190610 
-Djetty.base=/opt/web/jgobase -Djava.io.tmpdir=/opt/jetty/temp
JETTY_HOME            =  /opt/jetty/jetty-distribution-9.4.19.v20190610
JETTY_BASE            =  /opt/web/jgobase
START_D               =  /opt/web/jgobase/start.d
START_INI             =  /opt/web/jgobase/start.ini
JETTY_START           =  
/opt/jetty/jetty-distribution-9.4.19.v20190610/start.jar
JETTY_CONF            =  
/opt/jetty/jetty-distribution-9.4.19.v20190610/etc/jetty.conf
JETTY_ARGS            =  jetty.state=/opt/web/jgobase/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           =  /opt/web/jgobase/jetty.state
JETTY_START_TIMEOUT   =  60
RUN_CMD               =  /usr/bin/java 
-Djetty.home=/opt/jetty/jetty-distribution-9.4.19.v20190610 
-Djetty.base=/opt/web/jgobase -Djava.io.tmpdir=/opt/jetty/temp -jar 
/opt/jetty/jetty-distribution-9.4.19.v20190610/start.jar 
jetty.state=/opt/web/jgobase/jetty.state jetty-started.xml


Does it matter that the JAVA_OPTIONS field does not match the tutorial? The 
tutorial has a reference to -Djava.logs entry (and also a -Djetty.state entry).


Here are the file permissions from $JETTY_BASE:

root@localhost:/opt/web/jgobase# ls -l
total 12
drwxr-xr-x 2 jetty root 4096 Aug  7 22:05 logs
-rw-r--r-- 1 jetty root 2427 Aug  7 20:49 start.ini
drwxr-xr-x 2 jetty root 4096 Aug  7 20:25 webapps


Here is the line from /etc/passwd for the "jetty" user:

jetty:x:1000:1000::/opt/jetty/temp:/bin/false


It seems the code is trying to literally use "/libs" instead of 
$JETTY_BASE/libs.

Here is what we have from start.ini. Basically just using defaults.

# ---------------------------------------
# Module: console-capture
# Redirects JVMs console stderr and stdout to a log file,
# including output from Jetty's default StdErrLog logging.
# ---------------------------------------
--module=console-capture

## Logging directory (relative to $jetty.base)
# jetty.console-capture.dir=logs

## Whether to append to existing file
# jetty.console-capture.append=true

## How many days to retain old log files
# jetty.console-capture.retainDays=90

## Timezone of the log timestamps
# jetty.console-capture.timezone=GMT


As an experiment, changing the above to the following does allow the program to 
work as a service:

jetty.console-capture.dir=/opt/web/jgobase/logs

But I find this worrying, given that the comment explicitly says "relative to 
$jetty.base". That seems to imply somewhere in the process of running the 
service $jetty.base is being interpreted as a blank or empty field.

One last note, a collaborator has made a file and placed it in the following 
location.

/etc/systemd/system/jetty.service

I am wondering if this file is involved in the error. It wasn't listed in the 
tutorial as being part of the process of creating a service. Could this be 
intercepting in a way that causes the code to lose the correct logging address?

Here is what is in it.

[Unit]
Description=Jetty
After=network-online.target

[Service]
Type=simple
User=jetty
Group=jetty
ExecStart=/usr/bin/java -jar 
/opt/jetty/jetty-distribution-9.4.19.v20190610/start.jar 
jetty.home=/opt/jetty/jetty-distribution-9.4.19.v20190610 
jetty.base=/opt/web/jgobase jetty.http.port=8080
ExecStop=/bin/kill ${MAINPID}
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target


Thank you for any assistance!
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to