Starting Java Application in init.d without Long Classpath in Command Line
The key is to use interesting /usr/bin/env command with launches Java process with given environment variables (e.g. CLASSPATH) and key return Java’s PID :)
. /lib/lsb/init-functions LIMIT_OFILE=102400 ulimit -n $LIMIT_OFILE options="CLASSPATH=$CP /usr/lib/jvm/java-6-sun/bin/java $JAVA_OPTS $MAIN_CLASS $OPTS" if start-stop-daemon -v -b -m --oknodo -c $USER --start --quiet -d $bin_dir --pidfile "$pid_dir/myapp-$1.pid" --exec /usr/bin/env -- $options; then log_end_msg 0 else log_end_msg 1 fi
so you can type
ps auxw | grep java
and enjoy short process names. long live linux!
Very Important Update: start-stop-daemon starts processes in none interactive mode and hence does not care about the limits you set in /etc/security/limits.conf . Unfortunately start-stop-daemon itself also does not provide any mechanism to see ulimits and hence one has to see its own limits via ulimits command before running above command inside the script.
While the application is running, its limits values are visible in the /proc file system.
sudo cat /proc/[PID]/limits sudo ls -1 /proc/[PID]/fd/ | wc -l
Leave a Comment