LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   The init-script is not started during reboot (https://www.linuxquestions.org/questions/linux-software-2/the-init-script-is-not-started-during-reboot-4175472422/)

thomas2004ch 08-07-2013 06:44 AM

What do you mean "doesn't necessarily reflect the correct init-script name"?

Here it is:

Code:

# ls -l /etc/rc*d/*jboss*
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc0.d/K02jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc1.d/K02jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc2.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc3.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc4.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc5.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc6.d/K02jboss -> ../init.d/jboss


druuna 08-07-2013 06:55 AM

Quote:

Originally Posted by thomas2004ch (Post 5004746)
What do you mean "doesn't necessarily reflect the correct init-script name"?

The init script mentions # chkconfig: 3 81 02, this says that the script should be started in level 3, that its start priority should be 81, and that its kill priority should be 02. However, depending on how things are created, this doesn't mean that the scripts have the correct Sxx en Kyy part that is mentioned.

Quote:

Here it is:

Code:

# ls -l /etc/rc*d/*jboss*
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc0.d/K02jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc1.d/K02jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc2.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc3.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc4.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 08:36 /etc/rc5.d/S81jboss -> ../init.d/jboss
lrwxrwxrwx 1 root root 18 Aug  6 07:04 /etc/rc6.d/K02jboss -> ../init.d/jboss


This looks OK.

You mention 2 jboss instances are installed are you sure one isn't frustrating the other during boot?

Not sure what else to tell you which can solve this......

thomas2004ch 08-07-2013 07:07 AM

I am sure the other Jboss not frustrates the other during boot, since I've tried disable the other by means of "chkconfig jboss7 off". This means the other Jboss (jboss7) will not restart during reboot.

No problem, I will check it further.

Firerat 08-07-2013 11:02 AM

to aid diagnostics, you could add

set -x
exec 2&>1 >> /path/to/somelog

just below shebang in init-script, along with /opt/jboss/current/bin/run.sh
( based on druuna's link )

also probably need to remove
> /dev/null 2> /dev/null

thomas2004ch 08-08-2013 01:01 AM

Hi Firerat,

Here i smy init-script. Could you teld me where should I add the code you mentioned?

Code:

#!/bin/sh
#
# $Id: jboss_init_redhat.sh 99350 2010-01-13 17:05:27Z bshim $
#
# JBoss Control Script for jboss
#
# chkconfig: 3 81 02
 
# To use this script run it as root - it will switch to the specified user
#
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself.
#
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.

JBOSS_USER=`basename $0`
. /home/$JBOSS_USER/.bash_profile

#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss"}

#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"jboss"}

#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/usr/local/jdk/bin"}

#configuration to use, usually one of 'minimal', 'default', 'all', 'production'
JBOSS_CONF=${JBOSS_CONF:-"default"}

#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}

#define the script to use to start jboss
#JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}

if [ "$JBOSS_USER" = "RUNASIS" ]; then
  SUBIT=""
else
  SUBIT="su - $JBOSS_USER -c "
fi

if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
  # ensure the file exists
  touch $JBOSS_CONSOLE
  if [ ! -z "$SUBIT" ]; then
    chown $JBOSS_USER $JBOSS_CONSOLE
  fi
fi

if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
  echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
  echo "WARNING: ignoring it and using /dev/null"
  JBOSS_CONSOLE="/dev/null"
fi

#define what will be done with the console log
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}

JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"

if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
  export PATH=$PATH:$JAVAPTH
fi

if [ ! -d "$JBOSS_HOME" ]; then
  echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
  exit 1
fi

echo JBOSS_CMD_START = $JBOSS_CMD_START

function procrunning() {
  procid=0
  JBOSSSCRIPT=$(echo $JBOSSSH | awk '{print $1}' | sed 's/\//\\\//g')
  for procid in `/sbin/pidof -x "$JBOSSSCRIPT"`; do
      ps -fp $procid | grep "${JBOSSSH% *}" > /dev/null && pid=$procid
  done
}


stop() {
    pid=0
    procrunning
    if [ $pid = '0' ]; then
        echo -n -e "\nNo JBossas is currently running\n"
        exit 1
    fi

    RETVAL=1

    # If process is still running

    # First, try to kill it nicely
    for id in `ps --ppid $pid | awk '{print $1}' | grep -v "^PID$"`; do
      if [ -z "$SUBIT" ]; then
          kill -15 $id
      else
          $SUBIT "kill -15 $id"
      fi
    done

    sleep=0
    while [ $sleep -lt 120 -a $RETVAL -eq 1 ]; do
        echo -n -e "\nwaiting for processes to stop";
        sleep 10
        sleep=`expr $sleep + 10`
        pid=0
        procrunning
        if [ $pid == '0' ]; then
            RETVAL=0
        fi
    done

    # Still not dead... kill it

    count=0
    pid=0
    procrunning

    if [ $RETVAL != 0 ] ; then
        echo -e "\nTimeout: Shutdown command was sent, but process is still running with PID $pid"
        exit 1
    fi

    echo
    exit 0
}

case "$1" in
start)
    cd $JBOSS_HOME/bin
    if [ -z "$SUBIT" ]; then
        eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
    else
        $SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"
    fi
    ;;
stop)
    stop
    ;;
restart)
    $0 stop
    $0 start
    ;;
*)
    echo "usage: $0 (start|stop|restart|help)"
esac


Firerat 08-08-2013 02:40 AM

actually, exec won't work with sh, AND I had typo with teh redirection

Code:

#!/bin/sh
if (( $# == 2 )); then
    set -x
elif (( $# == 1 )); then
    /bin/sh $0 $1 diag > /path/to/somelog 2>&1
    exit
fi

will send some noise to /path/to/somelog

It will tell you 1/ if the script started, 2/ where it stopped

Firerat 08-08-2013 03:10 AM

just re-looking at this

I notice Jboss7 starts just before Jboss5

In Jboss5, start is executing JBOSS_HOME/bin/run.sh in background
Is Jboss7 executing the same script? ( are they the same user "jboss" ? )

what does $JBOSS_HOME/bin/run.sh do?

chances are they are both running at the same time, which may go some way to explaining why "on boot" jboss5 fails, but works 'manually' later

thomas2004ch 08-09-2013 01:45 AM

Quote:

Originally Posted by Firerat (Post 5005385)
actually, exec won't work with sh, AND I had typo with teh redirection

Code:

#!/bin/sh
if (( $# == 2 )); then
    set -x
elif (( $# == 1 )); then
    /bin/sh $0 $1 diag > /path/to/somelog 2>&1
    exit
fi

will send some noise to /path/to/somelog

It will tell you 1/ if the script started, 2/ where it stopped

Your tip helped. Here is what I got from the '/path/to/somelog'

Code:

++ basename /etc/rc3.d/S81jboss
+ JBOSS_USER=S81jboss
+ . /home/S81jboss/.bash_profile
/etc/rc3.d/S81jboss: line 28: /home/S81jboss/.bash_profile: No such file or directory

This error comes from the line

Code:

...
JBOSS_USER=`basename $0`
...

I wonder how the JBOSS_USER could be 'S81jboss'? Normally it should take the value of the init-script name, i.e. 'jboss'.

After I replaced this line to
Code:

...
JBOSS_USER=jboss

Then it's OK and the Jboss could be started during rebooting.

Firerat 08-09-2013 05:35 AM

Quote:

Originally Posted by thomas2004ch (Post 5006069)
Your tip helped. Here is what I got from the '/path/to/somelog'

Code:

++ basename /etc/rc3.d/S81jboss
+ JBOSS_USER=S81jboss
+ . /home/S81jboss/.bash_profile
/etc/rc3.d/S81jboss: line 28: /home/S81jboss/.bash_profile: No such file or directory

This error comes from the line

Code:

...
JBOSS_USER=`basename $0`
...

I wonder how the JBOSS_USER could be 'S81jboss'? Normally it should take the value of the init-script name, i.e. 'jboss'.

After I replaced this line to
Code:

...
JBOSS_USER=jboss

Then it's OK and the Jboss could be started during rebooting.

:)
S81jboss is the symlink in the rc*.d/ directories
$0 is returning the path to the command that invoked the shell
( I didn't explain that very well )

Anyhow , sorted
no need for those 'loglines' now


All times are GMT -5. The time now is 07:18 PM.