Restarting Jetty on Ubuntu 12.04.4 - jetty

I'm getting some very unusual behaviour.
I followed these instructions for installing jetty but used the latest version instead (9.1.1v20140108)
I had reason to restart Jetty and found I was getting these errors (logged in as root)
Starting Jetty: FAILED Wed Feb 5 12:35:59 EST 2014
So I spent 30 mins looking for an answer, then for reasons I can't recall, I did service jetty check and it was running (had a pid).
So I tried again with service Jetty stop:
root#erp:/var/log# service jetty stop
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Stopping Jetty: start-stop-daemon: warning: failed to kill 7817: No such process
1 pids were not killed
No process in pidfile '/var/run/jetty.pid' found running; none killed.
OK
None killed? Ok. Let's check that:
root#erp:/var/log# service jetty check
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Checking arguments to Jetty:
START_INI = /srv/jetty/start.ini
JETTY_HOME = /srv/jetty
JETTY_BASE = /srv/jetty
JETTY_CONF = /srv/jetty/etc/jetty.conf
JETTY_PID = /var/run/jetty.pid
JETTY_START = /srv/jetty/start.jar
JETTY_LOGS = /srv/jetty/logs
CLASSPATH =
JAVA = /usr/bin/java
JAVA_OPTIONS = -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state -Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty -Djava.io.tmpdir=/tmp
JETTY_ARGS = jetty.port=8085 jetty-logging.xml jetty-started.xml
RUN_CMD = /usr/bin/java -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state -Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty -Djava.io.tmpdir=/tmp -jar /srv/jetty/start.jar jetty.port=8085 jetty-logging.xml jetty-started.xml
No PID? Let's check that:
root#erp:/var/log# service jetty start
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Starting Jetty: FAILED Wed Feb 5 12:39:43 EST 2014
Ok, is there a PID?
root#erp:/var/log# service jetty check
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Checking arguments to Jetty:
[edit]
Jetty running pid=7993
Weird. Sure enough, a stop and check will give the same results.
What's going on with the jetty startup script? And why am I getting FAILED errors on start which are incorrect, and fail to remove pid errors on stop which are also incorrect?

I have got a fix for all those who have been using that tutorial to install jetty
nano /etc/init.d/jetty
And change this syntax :
start-log-file="$JETTY_LOGS/start.log"
to
start-log-file="start.log"
It will fix everything in the latest jetty build and make it run like a charm.
Hope I could be of help

Ok, so this was a tricky one that was the result of a recent Java update.
I jumped into the jetty.sh at /etc/init.d/jetty and grabbed out the actually executed line:
$ /usr/bin/java -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state \
-Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty \
-Djava.io.tmpdir=/tmp -jar /srv/jetty/start.jar jetty.port=8085 \
jetty-logging.xml jetty-started.xml
and I got this:
java.io.IOException: Cannot read file: modules/npn/npn-1.7.0_51.mod
at org.eclipse.jetty.start.Modules.registerModule(Modules.java:405)
at org.eclipse.jetty.start.Modules.registerAll(Modules.java:395)
at org.eclipse.jetty.start.Main.processCommandLine(Main.java:561)
at org.eclipse.jetty.start.Main.main(Main.java:102)
Which in turn lead me to this solution on the eclipse dev list:
$ cp /srv/jetty/modules/npn/npn-1.7.0_45.mod /srv/jetty/modules/npn/npn-1.7.0_51.mod
$ chown jetty:jetty /srv/jetty/modules/npn/npn-1.7.0_51.mod
Sure enough, Jetty restarted without hassle.

Try running below command in terminal.
sudo service jetty9 stop

I run Jetty 9.2.10.v201503 on pcDuino v3, Ubuntu 14.04. According to my experience with this relatively slow platform, this message may be reported when Jetty server itself starts longer than internal waiting loop in /etc/init.d/jetty script expects.
After adding “set –x” at the beginning of /etc/init.d/jetty file and running that script I noticed that internal waiting loop is implemented as “for” making 15 steps and periodically checking content of the $JETTY_BASE/jetty.state file.
After waiting additional couple of seconds, Jetty server is up and running ok, no errors/warrnings in log files.

Related

What is the a way to find "illegal characters found in URL"?

I have remote linux server and I am trying to build jenkins image from Dockerfile.
As I mounting local folder to the image, jenkins is not able to install necessary plugins.
I follow the advices from Official Jenkins Image: Installing more tools.
During building process I get an error:
=> ERROR [3/3] RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt------> [3/3] RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt:
#0 0.292 WARN: plugins.sh is deprecated, please switch to install-plugins.sh
#0 0.293 Analyzing war: /usr/share/jenkins/jenkins.war
#0 0.451 Downloading cloudbees-folder:6.9
#0 0.460 **curl: (3) Illegal characters found in URL**
Dockerfile:3
1 | FROM jenkins:2.60.3
2 | COPY plugins.txt /usr/share/jenkins/plugins.txt
3 | >>> RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt*
here is my content of plugins.txt file:
cloudbees-folder:6.9
antisamy-markup-formatter:2.7
build-timeout:1.28
credentials-binding:1.27.1
timestamper:1.21
ws-cleanup:0.44
ant:1.13
gradle:2.2
workflow-aggregator:2.7
github-branch-source:2.11.5
pipeline-github-lib:36.v4c01db_ca_ed16
pipeline-stage-view:2.31
git:5.0.0
subversion:2.17.0
ssh-slaves:2.854.v7fd446b_337c9
matrix-auth:3.1.6
pam-auth:1.10
ldap:659.v8ca_b_a_fe79fa_d
email-ext:2.93
mailer:1.34.2
I found one possible solution saying that Docker Jenkins Image - curl: (3) Illegal characters found in URL
there is different line endings between Windows and Mac OS.
however it did not help me. I would wait for your suggestions.

Clojure 1.9 command line tools - command not found clj.sh

I have just installed clojure 1.9 on my mac via Homebrew.
As expected I get 2 links in /usr/local/bin to the actual executables
clojure# -> ../Cellar/clojure/1.9.0.358/bin/clojure
clj# -> ../Cellar/clojure/1.9.0.358/bin/clj
running clojure from the command line works
$ clojure
Clojure 1.9.0
user=>
but for not for the command line tools
$ clj
zsh: command not found: clj.sh
both executable files exist
$ ls Cellar/clojure/1.9.0.358/bin
clj* clojure*
I've tried uninstalling clojure with brew uninstall and have deleted the cached version of clojure-tools-1.9.0.358.tar.gz in my ~/Library/Caches/Homebrew/ directory.
Installing it again was successful
$ brew install clojure
==> Downloading https://download.clojure.org/install/clojure-tools-1.9.0.358.tar.gz ####### 100.0%
==> ./install.sh /usr/local/Cellar/clojure/1.9.0.358
🍺 /usr/local/Cellar/clojure/1.9.0.358: 9 files, 19.4MB, built in 31 seconds
but still the same error.
Interestingly if I use the Finder to locate the file and double click on it, a new terminal window opens up and things seem to work.
Last login: Tue Mar 6 10:35:48 on ttys002
/usr/local/Cellar/clojure/1.9.0.358/bin/clj ; exit;
$ /usr/local/Cellar/clojure/1.9.0.358/bin/clj ; exit;
Clojure 1.9.0
user=>
Any ideas please on why this executable won't run directly from the command line?
Many thanks
The problem was that I'd set up an alias for clj in my shell profile file which referenced a shell script called clj.sh that I'd written but which no longer exists - hence why nothing happened except an error message.
Removing the alias from the shell profile file corrected the problem.

pygame.init() fails when run with systemd

I'm trying to run a python pygame script with systemd and for some reason the script just exits without an error.
This is on a Raspberry Pi with Raspian "Jessie lite".
If I run the script manually with "sudo python myscript.py" it works fine.
sudo systemctl status myscript.service reports:
* myscript.service - Python Script
Loaded: loaded /etc/systemd/system/myscript.service; enabled) Active: inactive (dead) since Mon 2016-08-29 04:33:19 UTC; 1s ago
Process: 3275> ExecStart=/usr/bin/python /home/pi/myscript.py (code=killed, signal=HUP)
Main PID: 3275 (code=killed, signal=HUP)
If I start the service manually with sudo systemctl start myscript.service the same thing happens.
I've stripped down my script to just the pygame.init() call. This is where it exits.
If I try to initialize the modules manually then "cdrom", "joystick", "threads", and "font" initialize normally but a call to display.init() causes the program to exit. There is no exception raised.
The only resource I could find online is this guy. It seems he ran into the exact same thing I'm seeing.
I've tried strace and if I wait long enough (2 minutes), it will work!
Obviously I can't run with strace all the time. I think it slows down the execution of the initialization to somehow allow it to work.
EDIT:
So the issue appears to be systemd sending a SIGHUP. If this is unhandled in Python the default action is to exit. A quick fix is the catch SIGHUP:
import signal
def handler(signum, frame):
pass
try:
signal.signal(signal.SIGHUP, handler)
except AttributeError:
# Windows compatibility
pass
So many burning questions. Why does systemd do this? Why does strace fix the issue? Why do some Python scripts get SIGHUP while others don't?
I don't have an answer, but I'm experiencing the same thing, so I'll add some more detail.
Here's the cut-down code:
#!/usr/bin/python2.7
import logging
from pygame import display
import signal
import time
def handler(signum, frame):
"""Why is systemd sending sighups? I DON'T KNOW."""
logging.warning("Got a {} signal. Doing nothing".format(signum))
signal.signal(signal.SIGHUP, handler)
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGCONT, handler)
logging.warning("About to start display.")
try:
display.init() # hups
except Exception as ex:
logging.warning("Got any exception: %s " % ex)
logging.warning("Quitting in 60")
time.sleep(60)
Here's the log that produces:
Jul 8 22:30:27 beardog systemd[1]: Started PyGame Test.
Jul 8 22:30:27 beardog pygame[17406]: WARNING:root:About to start display.
Jul 8 22:30:27 beardog pygame[17406]: WARNING:root:Got a 1 signal. Doing nothing
Jul 8 22:30:27 beardog pygame[17406]: WARNING:root:Got a 18 signal. Doing nothing
Jul 8 22:30:27 beardog pygame[17406]: WARNING:root:Quitting in 60
It's getting a SIGCONT immediately after the SIGHUP, but no SIGTERM. Systemd claims to only ever send a SIGHUP after a SIGTERM, so maybe it's coming from somewhere else? I can't find anything relevant in the pygame code though.
I've turned on systemd debug logging, but it doesn't print anything interesting.
Here's my systemd config.
[Unit]
Description=PyGame Test
After=syslog.target network.target network-online.target graphical.target
[Service]
Type=simple
WorkingDirectory=/path/to/code/pygame/
ExecStart=/path/to/code/pygame/why.py
Restart=always
RestartSec=5
LimitNOFILE=10000
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=pygame
SendSIGHUP=no
[Install]
WantedBy=multi-user.target
I've tried this as Type=forking, oneshot and dbus (although it isn't any of them). I've also tried TimeoutStartSec=20, but no change. Tested on an Ubuntu Xenial laptop and on a Raspberry pi running Raspbian. Both python2.7 and python3. Code works fine when run manually, and seems to work when run under strace in systemd. /o\
Like the OP, I can work around it by catching the SIGHUP, but after this much debugging I'd love to know what's going on.
For me the solution was to only init specific modules which I needed.
In my case instead pygame.init() I initialized only pygame.mixer.init() and now systemd can start the service.
First, check your logs:
journalctl -u myservice.service
Adding this to your unit file may improve the logging:
StandardOutput=journal+console
In some cases if some logging happens just before the service exits, the logs won't get tagged with the the service, so after you run the service, also look at:
journalctl
For entries just after your service exited.
Also, instead using the network.target, try the network-online.target.
I presume the app runs OK from the command line by itself. Assuming it works that way and not from systemd, differing environment variables can be an issue. Add a line to the top of your app to dump all the environment variables and compare that output when run from systemd vs the CLI.
Finally, review the docs for Type=. If the default Type= doesn't apply to your case, set this appropriately.
Future questions specific to systemd may be better answered at the Unix & Linux StackExchange as they don't directly relate to programming.
You should also post your systemd unit file since that's what you are having trouble with.

getting 'cgroup change of group failed' when trying to add process to cgroup

I did the following both on Ubuntu 14 and SUSE Linux Enterprise Server 11 (x86_64) where libcgroup is installed, with root:
cgcreate -t ngam:home -a ngam:home -g cpuset:/nadav2ndCpuSet
cgset -r cpuset.cpus=1 nadav2ndCpuSet
After that, if you cat /sys/fs/cgroup/cpuset/nadav2ndCpuSet/cpuset.cpus,
you will get:
1
which is good! as it is supposed to work.
Then, from user ngam, I ran the following cmd:
cgexec -g cpuset:nadav2ndCpuSet ~/whileLoop
where whileLoop is just a simple program that runs in a loop doing sqrt.
After that, I got the following error msg:
cgroup change of group failed
Why is it happening?
Thanks!
I ran into something similar while playing with cgroups on Ubuntu 16.04 just now.
When using the controller cpuset, cpus and mems are not initiated. Therefor you manually have to do it. Since you already specified cpuset.cpus you only need to set cpuset.mems
simply running
echo 0 > /sys/fs/cgroup/cpuset/nadav2ndCpuSet/cpuset.mems
or
cgset -r cpuset.mems=0 nadav2ndCpuSet
would solve your problem.
for more info on cpuset see http://man7.org/linux/man-pages/man7/cpuset.7.html
What I found is I forgot to make cgconfig start with system reboot, so a simple systemctl start cgconfig resolve the problem, and then do not forget systemctl enable cgconfig to make it start with system reboot.
I know my this answer might not be relevant to the question. I hope when people search the error cgroup change of group failed, this answer could help them.
BTW: systemctl start cgconfig is for centos 7, for centos 6 you may use service cgconfig start / chkconfig cgconfig on

uwsgi installation error in windows 7

Trying to install uwsgi according to documentation. I'm getting the below error on Windows 7.
What should I do?
(uwsgi-tutorial) C:\Users\Home\Videos\uwsgi-tutorial\mysite>pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.11.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi\setup.py", line 3, in <module>
import uwsgiconfig as uc
File "uwsgiconfig.py", line 8, in <module>
uwsgi_os = os.uname()[0]
AttributeError: 'module' object has no attribute 'uname'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi
uWSGI can be compiled on Windows only using cygwin. There is no such thing as uname in normal Windows console, but it exists inside cygwin. If you're already in cygwin console, try to run uname command, if that exists, check if os.uname() in python inside cygwin is also working.
Latest news from the front, uWSGI perfectly works on Windows 10 in bash on Ubuntu on Windows
As Linux subsystem still in beta, i'd not recommend for production usage, however this will cover all dev needs.
P.S. i know that op ask about Windows 7, however as Windows 10 and Linux subsystem come to Windows world later, i think i can leave this here.
uWSGI can be compiled on Windows using Cygwin. But unfortunately, I was getting the same message with the Cygwin.
Here I am sharing the other way to install uWSGI on windows.
Step 1: Download the stable release and extract the tar file
Step 2: Open uwsgiconfig.py and import platform then replace os.uname()[index] with platform.uname()[index]
Change
uwsgi_os = os.uname()[0]
uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]
To
import platform
uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]', platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]
Step 3: Run python setup.py install
Note: You may need to install GCC and configure it.