I have gone through almost every SO and Google article to try to make this happen but still the Java app isnt starting at boot!
I get a message in syslog to say its 'Starting FXC-API' but the Java doesnt actually run.
This is my startup script.
#! /bin/sh
### BEGIN INIT INFO
# Provides: fxc-api
# Required-Start: $syslog exim4
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and Stop
# Description:
### END INIT INFO
case "$1" in
start)
logger Starting FXC-API
sh /opt/fix/fttglobal/1.0/start.sh
;;
stop)
logger Stopping FXC-API
sh /opt/fix/fttglobal/1.0/stop.sh
;;
*)
echo "Usage: /etc/init.d/fxc-api {start|stop}"
exit 1
;;
esac
exit 0
If I run this manually, ie service fxc-api start, then it starts no problem.
The start.sh script looks like this
#! /bin/sh
cd "$(dirname "$0")"
java -classpath ".:./libs/*" MainController &
Worked it out, I was missing the following in my /etc/init.d script above case
# Java path
JAVA_HOME=/usr/lib/java/jre
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
A note: Run the java like this
java -classpath ".:./libs/*" MainController > ./logs/log.txt 2> ./logs/errors.txt < /dev/null &
Related
when I run the command
mvn version
in ubuntu I get the following error.
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/java-7-openjdk-amd64/bin/java
My java version is
java version "1.8.0_91" Java(TM) SE Runtime Environment (build
1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
And I run
sudo nano /etc/environment
command and set java home and maven as
JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre"
M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
MAVEN_HOME=/usr/local/apache-maven/apache-maven-3.2.5
M2=/usr/local/apache-maven/apache-maven-3.2.5/bin
And my path variable is -
/usr/share/maven3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/jre:/home/hduser/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/hadoop/bin:/usr/lib/sqoop/bin:/home/hduser/bin:/usr/lib/jvm/java-8-oracle/jre/bin
And run command
sudo nano ~/.bashrc
and set these at the end
JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export JRE_HOME
export PATH export M2_HOME=/usr/share/maven3 export M2=$M2_HOME/bin
export PATH=$M2:$PATH
I have install java 8 and remove java 7 and then run the mvn command and I am getting this error. I am curious to know why it is showing java 7 rather then java 8 and Please also suggest me some solution.
Thanks in advance
EDIT
My bashrc is -
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user#host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u#\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*al$
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#=======================================
# Added by TKS to conexport PATH=$JAVA_HOME/bin:$PATH
figure HDFS
#=======================================
#HADOOP VARIABLES START
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
export HADOOP_HOME=/usr/local/hadoop
#export SQOOP_HOME=/usr/local/sqoop
export PATH=$PATH:$HADOOP_HOME/bin
#export PATH=$PATH:$SQOOP_HOME/bin
export SQOOP_HOME=/usr/lib/sqoop
#HADOOP VARIABLES END
JAVA_HOME=/usr/lib/jvm/java-8-oracle
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
I think your JAVA_HOME is supposed to be JDK and not JRE since Maven compile the Java code and there's no Java compiler (javac) in the JRE.
The following should be enough :
JAVA_HOME=/usr/lib/jvm/java-8-oracle
M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
PATH=$PATH:$JAVA_HOME/bin
PATH=$PATH:$M2_HOME/bin
Remove other M2 or MAVEN_HOME variables that you have declared.
I'm using the play-plugin (https://wiki.jenkins-ci.org/display/JENKINS/play-plugin) in jenkins to clean, compile and build the application, but when I run the application using a managed script (https://wiki.jenkins-ci.org/display/JENKINS/Managed+Script+Plugin) in jenkins, the app starts and stops immediately without any errors.
Anyone have any clue?
managed script
#!/bin/bash
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================
#
#
# Check this blog post I wrote with detailed information:
# http://buransky.com/play-framework/init-d-shell-script-for-play-framework-distributed-application/
#
#
# Script to start, stop and check status of a Play framework application. It requires
# the Play application to be packaged using the "dist" command. Before you run the script,
# you have to set values of NAME, PORT and APP_DIR variables.
#
# NAME – name of the application, must be the same as the name of shell script
# generated by Play framework to run the app
# PORT – port number at which the app should run
# APP_DIR – path to directory where you have unzipped the packaged app
#
#
# Usage: control.sh {start|stop|status|restart}
# port - requred for start and restart commands
#
# Example: control.sh restart app-name 9000
#
#
# The script uses RUNNING_PID file generated by Play framework which contains ID of the
# application server process.
#
#
# START YOUR APPLICATION WHEN MACHINE STARTS
# ==========================================
#
# The script uses RUNNING_PID file generated by Play framework which contains ID of
# the application server process.
#
#
# SAFE START
# ==========
#
# After starting the application the script checks whether the RUNNING_PID file has
# been created and whether the process is really running. After that it uses wget
# utility to issue an HTTP GET request for root document to do yet another check
# whether the server is alive. Of course this assumes that your application serves
# this document. If you don’t like (or have) wget I have provided curl version for
# your convenience as well.
#
#
# SAFE STOP
# =========
#
# Stop checks whether the process whose ID is in the RUNNING_PID file really belongs
# to your application. This is an important check so that we don’t kill an innocent
# process by accident. Then it sends termination signals to the process starting
# with the most gentle ones until the process dies.
#
#
# Script arguments (start, stop, restart or status)
COMMAND=$1
# ***********************************************
# ************* Set these variables ***********
NAME=Name
PORT=9001
APP_DIR=PATH
# ***********************************************
# ***********************************************
# Additional arguments to be passed to the Play application
APP_ARGS=-Dhttp.port=${PORT}
# Path to the RUNNING_PID file containing process ID
PID_FILE=$APP_DIR/RUNNING_PID
# Helper functions
echoProgress()
{
setColor 6
printf "%-70s" "$1..."
resetColor
return 0
}
echoError()
{
setColor 6
#printf "ERROR"
if [ ! -z "$1" ]
then
resetColor
#printf " [$1]"
fi
printf "\n"
resetColor
return 0
}
echoOK()
{
setColor 2
printf "OK"
if [ ! -z "$1" ]
then
resetColor
printf " [$1]"
fi
printf "\n"
resetColor
return 0
}
checkResult()
{
if [ "$1" -ne 0 ]
then
echoError "$2"
exit 1
fi
}
setColor()
{
tput setaf $1 2>/dev/null
}
resetColor()
{
tput sgr0 2>/dev/null
}
# Checks if RUNNING_PID file exists and whether the process is really running.
checkPidFile()
{
if [ -f $PID_FILE ]
then
if ps -p `cat $PID_FILE` > /dev/null
then
# The file exists and the process is running
return 1
else
# The file exitsts, but the process is dead
return 2
fi
fi
# The file doesn't exist
return 0
}
# Gently kill the given process
kill_softly()
{
SAFE_CHECK=`ps $# | grep [-]Duser.dir=$APP_DIR`
if [ -z "$SAFE_CHECK" ]
then
# Process ID doesn't belong to expected application! Don't kill it!
return 1
else
# Send termination signals one by one
for sig in TERM HUP INT QUIT PIPE KILL; do
if ! kill -$sig "$#" > /dev/null 2>&1 ;
then
break
fi
sleep 2
done
fi
}
# Get process ID from RUNNING_PID file and print it
printPid()
{
PID=`cat $PID_FILE`
printf "PID=$PID"
}
# Check port input argument
checkPort()
{
if [ -z "$PORT" ]
then
echoError "Port not set!"
return 1
fi
}
# Check input arguments
checkArgs()
{
# Check command
case "$COMMAND" in
start | stop | restart | status) ;;
*)
echoError "Unknown command"
return 1
;;
esac
# Check application name
if [ -z "$NAME" ]
then
echoError "Application name not set!"
return 1
fi
# Check application directory
if [ -z "$APP_DIR" ]
then
echoError "Application installation directory not set!"
return 1
fi
# Check port
case "$COMMAND" in
start | restart)
checkPort
if [ $? != 0 ]
then
return 1
fi
;;
esac
}
checkAppStarted()
{
# Wait a bit
sleep 3
# Check if RUNNING_PID file exists and if process is really running
checkPidFile
if [ $? != 1 ]
then
echoError
cat $TMP_LOG 1>&2
exit 1
fi
local HTTP_RESPONSE_CODE
# Issue HTTP GET request using wget to check if the app is really started. Of course this
# command assumes that your server supports GET for the root URL.
HTTP_RESPONSE_CODE=`wget -SO- "http://localhost:$PORT/" 2>&1 | grep "HTTP/" | awk '{print $2}'`
# The same functionality but using curl. For your convenience.
#HTTP_RESPONSE_CODE=`curl --connect-timeout 20 --retry 3 -o /dev/null --silent --write-out "%{http_code}" http://localhost:$PORT/`
checkResult $? "no response from server, timeout"
if [ $HTTP_RESPONSE_CODE != 200 ]
then
echoError "HTTP GET / = $HTTP_RESPONSE_CODE"
exit 1
fi
}
# Check input arguments
checkArgs
if [ $? != 0 ]
then
echo "Usage: $0 {start|stop|status|restart}"
exit 1
fi
case "${COMMAND}" in
start)
echoProgress "Starting $NAME at port $PORT"
checkPidFile
case $? in
1) echoOK "$(printPid) already started"
exit ;;
2) # Delete the RUNNING_PID FILE
rm $PID_FILE ;;
esac
SCRIPT_TO_RUN=$APP_DIR/bin/$NAME
if [ ! -f $SCRIPT_TO_RUN ]
then
echoError "Play script doesn't exist!"
exit 1
fi
# * * * Run the Play application * * *
TMP_LOG=`mktemp`
PID=`$SCRIPT_TO_RUN $APP_ARGS > /dev/null 2>$TMP_LOG & echo $!`
# Check if successfully started
if [ $? != 0 ]
then
echoError
exit 1
else
checkAppStarted
echoOK "PID=$PID"
fi
;;
status)
echoProgress "Checking $NAME at port $PORT"
checkPidFile
case $? in
0) echoOK "not running" ;;
1) echoOK "$(printPid) running" ;;
2) echoError "process dead but RUNNING_PID file exists" ;;
esac
;;
stop)
echoProgress "Stopping $NAME"
checkPidFile
case $? in
0) echoOK "wasn't running" ;;
1) PRINTED_PID=$(printPid)
kill_softly `cat $PID_FILE`
if [ $? != 0 ]
then
echoError "$PRINTED_PID doesn't belong to $NAME! Human intervention is required."
exit 1
else
echoOK "$PRINTED_PID stopped"
fi ;;
2) echoError "RUNNING_PID exists but process is already dead" ;;
esac
;;
restart)
$0 stop $NAME $PORT
if [ $? == 0 ]
then
$0 start $NAME $PORT
if [ $? == 0 ]
then
# Success
exit
fi
fi
exit 1
;;
esac
Turns out jenkins build process kills ANY child process it creates (https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller).
So to resolve this issue I had to add
export BUILD_ID=dontKillMe
to the process(shell script) that I wanted to continue running.
Not without seeing a setup, command or some log files. This is not a direct answer, but have you considered using Maven to run the app? This works for akka apps:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.yourapp.Hello</mainClass>
</configuration>
</plugin>
Edit to answer further comments: Native packager info
A sample build.sbt could look like this:
import com.typesafe.sbt.packager.archetypes.ServerLoader.SystemV
scalaVersion := "2.11.7"
val timestamp: Long = System.currentTimeMillis / 1000
name := """my-app"""
maintainer := "Me Me <me#me.io>"
packageName := """my-app"""
packageDescription := "My business logic."
packageSummary := "Test app."
version := s"1.0.0"
name in Universal := name.value
name in UniversalDocs <<= name in Universal
name in UniversalSrc <<= name in Universal
packageName in Universal := packageName.value
serverLoading in Debian := SystemV
...blah
fork in run := true
publishArtifact in(Compile, packageDoc) := false
publishArtifact in packageDoc := false
sources in(Compile, doc) := Seq.empty
enablePlugins {
DebianPlugin
JavaServerAppPackaging
}
And this would help you create a native Debian package with sbt debian:packageBin which can be controlled on the machine (once installed) with service <servicename> start|stop|restart
I've been trying to get my Java application to run as a daemon in the background after startup. I've followed the instructions given in the top answer here and to no avail.
This is my /etc/init.d/myapp file:
#!/bin/bash
# MyApp
#
# description: bla bla
case $1 in
start)
/bin/bash /var/lib/myapp/start.sh
;;
stop)
/bin/bash /var/lib/myapp/stop.sh
;;
restart)
/bin/bash /var/lib/myapp/stop.sh
/bin/bash /var/lib/myapp/start.sh
;;
esac
exit 0
as for the /var/lib/myapp/start.sh, it looks like this:
#!/bin/bash
java -jar myapp-1.0.0RC.jar &
and works fine when run from a terminal via ssh.
i also ran the update-rc.d myscript defaults command, and was only given a warning about headers and LSB
After this, once i reboot the server, the app isnt running. Any help is appreciated.
Thanks.
When bash scripts are run, they are not automatically ran from the same directory that contains them.
You will either need to update your scripts to change directory to that which holds the scripts before starting the jar:
#!/bin/bash
cd /var/lib/myapp/
java -jar myapp-1.0.0RC.jar &
Or, refer to the jar file with a full path:
#!/bin/bash
java -jar /var/lib/myapp/myapp-1.0.0RC.jar &
Check if your service is registered properly via chkconfig
$ chkconfig --list
If not you can see your service listed on the output, then try adding this lines to your script
#!/bin/bash
# chkconfig: 2345 95 20
# description: bla bla
# processname: myapp
and then run
chkconfig --add myapp
For more information you can check the man page for chkconfig
I have the following problem:
I am using Tomcat 6.0.32 and Java JDK 6.0_26. I have installed it successfully and the Tomcat start page is visible in the browser at port 8080.
I have also created $CATALINA_HOME/setenv.sh script and put some webapp-specific environment variables in it (along with the CATALINA_HOME, JAVA_HOME and CLASSPATH).
I have created a new user "tomcat", set a new home directory for him, and also passwd-ed it.
This script is being sourced from within a init script I created to start and stop Tomcat automatically on reboot. I do not use the standart startup.sh and shutdown.sh found in $CATALINA_HOME, but rather then jsvc daemon starter, so I can use port 8080 from a non-root process (Tomcat itself).
The actual problem is that, after restarting Tomcat my webapp does not receive or see the environment variable I set in setenv.sh and so it won't start.
I have tried to put the environment variable definition in various places:
.bashrc in the tomcat home directory
/etc/init.d/tomcat script
$CATALINA_HOME/bin/setenv.sh
$CATALINA_HOME/webapps/myapp/META-INF/context.xml
to no avail, after start of Tomcat my webapp does not see the required environment variables.
My question is - what the heck am I doing worng? Any suggsetions? How am I supposed to transfer env vars to an webapp if the setenv.sh does not work? What could make this mechanism faulty (allegedly this is the way to hand env vars to webapps)?
Here is the startup script I worte:
#!/bin/sh
### BEGIN INIT INFO
# Provides: allfaweb
# Required-Start: $syslog $apache $apache2 $httpd
# Should-Start:
# Required-Stop: $syslog $apache $apache2 $httpd
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: ALLFAweb service
### END INIT INFO
ALLFAWEB_BIN=/install/apache-tomcat-6.0.32-allfaweb/bin/jsvc
test -x $ALLFAWEB_BIN || { echo "$ALLFAWEB_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of setenv.sh file and read it
ALLFAWEB_CONFIG=/install/apache-tomcat-6.0.32-allfaweb/bin/setenv.sh
test -r $ALLFAWEB_CONFIG || { echo "$ALLFAWEB_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
. /etc/rc.status
rc_reset
. /install/apache-tomcat-6.0.32-allfaweb/bin/setenv.sh;
case "$1" in
start)
echo -n "Starting ALLFAweb ";
$ALLFAWEB_BIN \
-user tomcat \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-pidfile $ALLFAWEB_PID \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile $CATALINA_HOME/logs/catalina.err \
-cp $CLASSPATH org.apache.catalina.startup.Bootstrap
rc_status -v
;;
stop)
echo -n "Shutting down ALLFAweb "
$ALLFAWEB_BIN \
-stop \
-pidfile $ALLFAWEB_PID \
org.apache.catalina.startup.Bootstrap
rc_status -v
;;
restart)
$0 stop
$0 start
rc_status
;;
status)
echo -n "Checking for service ALLFAweb ";
/sbin/checkproc $ALLFAWEB_BIN
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
rc_exit
The system I am using is a SUSE SP2:
# uname -a
Linux testmachine 3.0.51-0.7.9-default #1 SMP Thu Nov 29 22:12:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Any help would be highly appreciated! Thanks in advance :)
You should be using system properties and not environment variables. Check the source for Tomcat's bin/daemon.sh script, which passes all of the standard variables to Tomcat when it is launched.
I found it. Allegedly the reason is that at first I started Tomcat 6 as root, and then changed the ownership of files to user "tomcat". The root process had written files all over the file system wiht the appropriate permissions, that is, the "tomcat" user could not read them.
The default shell of the "tomct" user was /bin/sh and not /bin/bash
I also deleted the files in $CATALINA_HOME/work and renamed the directory to which my custom env var was pointing to (and the env var accordingly).
There were also some logfiles generated from log4j in the / dicrectory, those are gone too and now everything works as expected :)
Thanks for all the feedback, you kept me going during these 3 days of frustration :)
Cheers!
I'm trying to deamonize my Java app using jsvc. This is my initscript
#!/bin/sh
# CONFIG
JSVC=/opt/jsvc/jsvc
JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
USER=gserv
ARGS=none
# END CONFIG
PIDFILE=/var/run/silvercar-gameserver.pid
LOGDIR=/var/log/silvercar-gameserver
case "$1" in
start)
export JAVA_HOME
cd `dirname $0`
$JSVC -jvm server -pidfile $PIDFILE -user $USER -outfile $LOGDIR/stdout -errfile $LOGDIR/stderr \
-cp `cat classpath` tr.silvercar.gameserver.runner.DeamonGameServer $ARGS
;;
stop)
$JSVC -stop -pidfile $PIDFILE
;;
esac
exit 0
When I run ./thisscript.sh start as root two things go wrong, and I suspect they're related:
The app starts, but its output is shown instead of saved to the specified outfile
The script doesn't exit, but blocks until I hit Ctrl+C.
What am I doing wrong?
I don't see anything wrong in your launch script; perhaps there is an issue in your service implementation DeamonGameServer. Try replacing your class with a simple Daemon skeleton implementation and see what happens.
Also, note there is an open defect in jsrv : Jsvc does not exit when all non-daemon threads are dead.