Tuesday, July 21, 2015

Daemon hell in Jenkins

Recently I wrote a Linux like initd script to start/stop my web application.

The script works well when running it in shell of linux. The web application will run in background by daemon.

However I found both daemon and web application(java) exited immediately if I started the script in Jenkins as a shell step of build process.

I put below simple script in 'Execute shell' block,

daemon --name=test-daemon -- sleep 200sleep 60

The process 'daemon' and 'sleep 200' should exit after 200 seconds the 'sleep' exits. The jenkins job will be finished in 60 secs.

jenkins   9954  9950  0 21:48 ?        00:00:00 sleep 60
jenkins   9955     1  0 21:48 ?        00:00:00 daemon —name=test-daemon — sleep 200
jenkins   9956  9955  0 21:48 ?        00:00:00 sleep 200

Above is the process info queried via ps command. The father pid of daemon is 1, not the script generated by Jenkins.
But both the process 'daemon' and 'sleep 200' immediately exited when the script finished. Should be something wrong in Jenkins to cause daemon exited unexpected.

It's something really frustrating to use daemon to stop/start the web application in Jenkins.

Finally I used **docker** container to run my web application, which easily can be stopped/started via script in Jenkins.

Monday, July 13, 2015

The symptoms of Java broken in Mac OSX 10.10 and fix solution

After uninstalling some applications from my Mac OSX, I found the applications that depends on JRE totally does not work. I noticed below symptoms,


  1. Eclipse Mars can not be launched, even though I specified the launching vm to another one(`java -version` still work). The SWT native library failed to resolve the dependencies to '/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM' which does not exists.
  2. I tried to reinstall Oracle 1.8.0_u45 via both brew and dmg image downloaded from Oracle website, both ways were failed as well.
  3. The Mac pkg Installer can not be started due to dylib broken. It means I can't install any pkg via GUI. The command line(such as `sudo installer -verboseR -target / -pkg /Volumes/OS\ X\ 10.10.4\ Update\ Combo/OSXUpdCombo10.10.4.pkg`) still works.
Finally I realized the problem was caused by I uninstalled the out of date Apple Java 6. Looks like all of above failures are required the system built-in Java. It really does not make sense the Oracle 1.8 installer script to depend on the out of date Java.

Finally I reinstalled Java for OS X 2014-001 to make everything working again. The GUI installer for pkg still does not work, you need use below command to use the pkg.


sudo installer -verboseR -target / -pkg /Volumes/Java\ for\ OS\ X\ 2014-001/JavaForOSX.pkg