jetty init file prints wrong reachable information
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
jetty (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
When starting/stopping Jetty via its init script (/etc/init.
This occurs in Ubuntu 14.04, but probably occurs in other Ubuntu/Debian versions since the `/etc/init.d/jetty` script is basically the same.
I will show some examples in a fresh install of Jetty (with `NO_START=0`) in a machine which hostname is `ip-172-31-45-218`.
```
root@ip-
* Starting Jetty servlet engine. jetty
* Jetty servlet engine started, reachable on http://
root@ip-
* Jetty servlet engine is running with pid 5477, and is reachable on http://
root@ip-
* Stopping Jetty servlet engine (was reachable on http://
* Jetty servlet engine stopped. jetty [ OK ]
```
Here, we have the first strange thing:
- Start/stop report reachable on http://
Running some curls:
```
root@ip-
curl: (7) Failed to connect to ip-172-31-45-218 port 8080: Connection refused
root@ip-
root@ip-
<HTML>
<HEAD>
<TITLE>Welcome to Jetty 6 on Debian</TITLE>
[...]
```
Even if we put `127.0.1.1 ip-172-31-45-218` or `172.31.45.218 ip-172-31-45-218` in `/etc/hosts`, as expected in Ubuntu hosts` in `/etc/hosts`, as expected in Ubuntu hosts, the first curl won't work.
This is because Jetty listens on 127.0.0.1 / ::1 when no host is informed:
```
root@ip-
tcp6 0 0 127.0.0.1:8080 :::* LISTEN 5613/jsvc.exec
```
The same thing will happen if we change Jetty to listen in a specific IP address different than the represented by the hostname.
Now, the second thing:
- Start/stop can print unreachable address (Jetty is NOT reachable in this address).
And the third:
- Status prints a strange address if `JETTY_HOST` is blank, and it should print 127.0.0.1
Now, if we change in `/etc/default/
```
root@ip-
* Jetty servlet engine is running with pid 5613, and is reachable on http://
root@ip-
tcp6 0 0 127.0.0.1:8080 :::* LISTEN 5613/jsvc.exec
```
The same thing would happen if we change the `JETTY_PORT` config.
So, the fourth point:
- Status can return wrong reachable information if the config file (host/port) was modified after Jetty had started
There are a lot of other inconsistencies.
In my opinion, it's easier to remove these informations in the init script (the admin can always check the config files and run netstat to get the correct info).
But a more complex fix should consider checking netstat on stop/status commands, and checking the border cases (empty host - Jetty defaults to 12.0.0.1 / empty port - Jetty defaults to what is set in its XML config files, or 8080 if nothing more is changed) .
Hi,
I discovered another strange and related behavior.
When leaving JETTY_HOST empty, instead of listening on all IPs (0.0.0.0 - IPv4 and IPv6), the server is listening on localhost (IPv4 127.0.0.1).
I run some tests and I discovered that passing an empty jetty.host as param is different than not setting it.
For example:
``` nnector@ 0.0.0.0: 8080
$ cd /usr/share/jetty/
$ java -jar start.jar
[...]
[main] INFO org.mortbay.log - Started SelectChannelCo
[CTRL+C] host=0. 0.0.0 -jar start.jar nnector@ 0.0.0.0: 8080
$ java -Djetty.
[...]
[main] INFO org.mortbay.log - Started SelectChannelCo
[CTRL+C] nnector@ :8080
$ java -Djetty.host= -jar start.jar
[main] INFO org.mortbay.log - Started SelectChannelCo
```
And if we check netstat in the last case:
```
netstat -nlp | grep jsvc
tcp6 0 0 127.0.0.1:8983 :::* LISTEN 24209/jsvc.exec
```
It is, if we pass `-Djetty.host=`, Jetty will listening on 127.0.0.1. This happens when JETTY_HOST is empty:
``` "$JAVA_ OPTIONS -Djava. io.tmpdir= $JETTY_ TMP \ $JETTY_ START_CONFIG \ home=$JETTY_ HOME -Djetty. logs=$LOGDIR \ host=$JETTY_ HOST -Djetty. port=$JETTY_ PORT"
JAVA_OPTIONS=
-DSTART=
-Djetty.
-Djetty.
```
A good solution for this is always set JETTY_HOST and do NOT recommend the user to set it blank (as is done today).
So, I'm proposing some changes to the /etc/default/jetty and /etc/init.d/jetty file.
What do you think, guys?