powered by Jive Software

Cannot get Jive to run as service in Linux

I am unable to get the Jive server to run as a service automatically whenever I start Linux (Mandriva 2005 LE/Mandrake 10.2). The computer is in my bedroom, so I have to turn it off every night, and it is very annoying having to go into a console and type “messenger start” every day.

I have had this problem for quite some time now, and upgrading to 2.3.0 did not help. I went through all of the instructions for getting messenger to run as a service, and they all failed. The odd thing is, though, on the bootup sequence, I do see "Starting messenger… ".

Another odd thing is that, although I have had the problem for some time, there was a time when it would work intermittently: start sometimes automatically and others not, with no detectable differences in the conditions in which it would do one rather than the other. I cannot think of anything in particular on the computer that has changed since the time that it would do that.

I should be most grateful for any assistance from anybody about this

Not sure what you mean by ‘‘service’’ unless you are referring to /etc/init.d scripts, but you can start apps from cron on boot by using the @reboot schedule time: Add the line ‘’@reboot /path/to/messenger/bin/messenger start’’ to your crontab file.

See man 5 crontab for more info.

I am referring to the /etc/init.d scripts. Do you have any idea why these might not be working? I’'d rather do it properly than have an offbeat cron job.

The syntax of init.d scripts is somewhat distro specific. I use suse 9.x and here’'s what I would do:

as root:

make a copy of /etc/init.d/skeleton

  1. cp /etc/init.d/skeleton /etc/init.d/jive

edit the newly created jive script to start/stop your server (requires a little scripting knowledge)

test the script from the shell to make sure it is working

  1. /etc/init.d/jive start

  2. /etc/init.d/jive stop

Once the script works, you will need to symlink the script from the desired runlevel directories. (I’'d use /etc/init.d/rc3.d and /etc/init.d/rc5.d) like so:

  1. cd /etc/init.d/rc3.d

  2. ln -s …/jive S99jive

  3. ln -s …/jive K01jive

  4. cd /etc/init.d/rc5.d

  5. ln -s …/jive S99jive

  6. ln -s …/jive K01jive

These symlinks will be called by init when entering and leaving the respective runlevels. The “S” designates a start operation and the “K” designates a kill operation. The numbers specify in which order init should execute the script. The way I’'ve described it, the jive script will be started last, and killed first for each runlevel.

You may want to review the man page for your distro. On suse I can “man 7 init.d.” If this doesn’'t work for you try “apropos init.d” and see if you can locate the man page like that.

Good Luck!

I’‘m not quite sure exactly what you’‘re suggesting that I do, I’‘m afriad: I’‘m using Mandrake/iva, not Suse, and I’'ve already followed the instructions to do the like thing that you are suggesting that came with the script in question.

I have tested the script by running it manually from the console, and it works fine: the command /etc/init.d/jive-messengerd start starts the messenger service, and the command /etc/init.d/jive-messengerd stop stops it.

There is already a symbolic link, as the instructions directed, to this in /etc/rc.5, 5 being my default runlevel.

I’‘m not quite sure exactly what you’'re suggesting

that I do, I’‘m afriad: I’'m using Mandrake/iva, not

Suse, and I’'ve already followed the instructions to

do the like thing that you are suggesting that came

with the script in question.

What script? From jive? From Mandrake?

I have tested the script by running it manually from

the console, and it works fine: the command

/etc/init.d/jive-messengerd start starts the

messenger service, and the command

/etc/init.d/jive-messengerd stop stops it.

There is already a symbolic link, as the instructions

directed, to this in /etc/rc.5, 5 being my default

runlevel.

Try hitting the symlink in the runlevel directory instead of the hard target and see if that works. If not, then the link is not pointing to the right target–broken. The only thing that comes to mind is that init is not locating the target correctly.

If Mandrake follows the SNN/KNN convention for specifying init script order, try relinking your script with a higher SNN. It may be that the script is being called before networking is enabled.

Also, if you haven’'t done so already, loog over your boot.log file or its Mandrake equivalent. There may be something there that scrolled by too fast for you to catch. If you like, post your last boot.log–maybe something will catch my eye that missed yours.

Good Luck

What script? From jive? From Mandrake?

From Jive.

Try hitting the symlink in the runlevel directory instead of the hard target and see if that works. If not, then the link is not pointing to the right target–broken. The only thing that comes to mind is that init is not locating the target correctly.

Thank you for that suggestion. That was helpful. I tried it, and it worked manually from the symbolic link.

If Mandrake follows the SNN/KNN convention for specifying init script order, try relinking your script with a higher SNN. It may be that the script is being called before networking is enabled.

I don’‘t know what SNN/KNN is, I’‘m afraid, but I’'m fairly sure that the "Starting messanger… " message is after the "Bringing up eth0… " message.

Also, if you haven’'t done so already, loog over your boot.log file or its Mandrake equivalent. There may be something there that scrolled by too fast for you to catch. If you like, post your last boot.log–maybe something will catch my eye that missed yours.

It’‘s 36.3Mb, and KWrite won’'t open it.

As far as the boot.log goes–If you do not have a log viewer, you can issue the following:

tail -n 500 boot.log > myTempLog

to save the last 500 lines to myTempLog

You will have to adjust the -n flag to catpure the correct start point for the last boot.

I get the feeling that we are dealing with a dependency issue here. I suspect that the messenger script is being called before all env vars are set or something. Make sure that JAVA_HOME and all env vars are set before the messenger script is called. The init process will run before your login shell, so if you set your JAVA_HOME in ~/.profile or ~/.bashrc or such, init will not see it. Not sure if /etc/profile is sourced before or after init. It wouldn’'t hurt to put the env vars in the actual startup script itself–or at least source them from their current location.

As for the SNN/KNN I was referring to–

The “S” refers to start, “K” to kill. The “NN” refers to a numeric order in which to call the (symlinked) scripts. For example, the symlinks:

S01serviceA

S02serviceB

S03serviceC

would start seviceA, serviceB, serviceC in that order based on the order of the “NN” portion of the symlink name. If serviceA should happen to depend on serviceB, then serviceA will fail because serviceB does not get called until after serviceA. You should see this convention used in your rc subdirectories (where the symlinks live.) If not, then mandrake does not support this (LSB) standard.

Try “locate S01” to see if any such exist on your machine.

I might also suggest adding some debug stuff to the jive messenger script itself to make sure that it can see all required vars when it is called.

For example,

echo $(date “+%F %H:%M:%S”) > /some/writable/location/myStartLog

echo $JAVA_HOME >> /some/writable/location/myStartLog

echo $CLASSPATH >> /some/writable/location/myStartLog

etc etc

This will varify the proper env vars are being seen and whether or not the messenger script is actually being called.

Sorry, I can’‘t be of more help, but I am not familiar with Mandrake’‘s boot process. I would definitley look into Mandrake’'s documentation on init scripts and compare that with the script you obtained from jive. It may be the obtained script is not appropraite for your version of Mandrake.

Good Luck!

Here’'s mine fore mandrake

#!/bin/sh

  1. description: Jive messenger is a java based jabber server

  2. chkconfig: 2345 99 00

case “$1” in

‘‘start’’)

/opt/jive_messenger/bin/./messenger start

touch /var/lock/subsys/jive-messenger

;;

‘‘stop’’)

/opt/jive_messenger/bin/./messenger stop

rm -f /var/lock/subsys/jive-messenger

;;

*)

echo “Usage: $0 { start | stop }”

;;

esac

exit 0

change your target as needed.

If you use webmin, highly recommended, it makes it very easy to add boot services and daemon’'s.

This won’‘t work with a stock Jive Messenger install, but until I get around to doing more with JM on Mandriva, you’'ll have to alter it yourself, or symlink directories to /var/lib/jive_messenger. But, this script works much better than the included Red Hat one.


#!/bin/sh

  1. jive_messenger This shell script takes care of starting and stopping

  2. Jive Messenger.

  1. chkconfig: 2345 85 15

  2. description: Jive Messenger is an XMPP server.

  1. Source function library.

. /etc/rc.d/init.d/functions

  1. Source networking configuration.

. /etc/sysconfig/network

  1. Setup variables

PROGNAME=“jive_messenger”

RUNUSER=“jive”

MESSENGER_HOME="/usr/local/$“
MESSENGER_VAR=”/var/lib/$"

MESSENGER_BIN="$/bin"

LOCKFILE="/var/lock/subsys/$“
PIDFILE=”/var/run/$.pid"

  1. Snapshot

    1. Release
      MESSENGER_EXE="$/messenger.sh" MESSENGER_EXE="$/messenger"
  2. Snapshot

    1. Release
  3. Check that networking is up.

  4. Check that files are in place
    STARTCMD=“cd “$”; $ &” STARTCMD=“cd “$”; $start &> /dev/null”[ $ = “no” ] && exit 0 [ -x “$” ] && [ -d “$” ] || exit 0

RETVAL=0

JIVE_PIDS=""

getjivepids() {

local jive_procs proc

JIVE_PIDS=""

jive_procs="$(ps -u ${RUNUSER} -o pid=)"

for proc in $jive_procs ; do

if ps -o args= -p $proc | grep -q “java.*$” ; then
if [ -z “$” ]; then
JIVE_PIDS="$“
else
JIVE_PIDS=”$ $"
fi
fi
done
return 0
}
start() {
if [ ! -f “${LOCKFILE}” ]; then
gprintf "Starting $: "

daemon --check “$” --user “$” "$"
RETVAL=$?
if ; then
getjivepids # Load PIDs of Jive Messenger into JIVE_PIDS
echo “$” > "$"
touch "$"
fi
echo
fi
return $RETVAL
}
stop() {
if [ -f “$” ]; then
gprintf "Shutting down $: "

killproc $
RETVAL=$?
rm -f "$"
echo
fi
return $RETVAL
}
restart() {
stop
start
}
mdkstatus() {
getjivepids # Load PIDs of Jive Messenger into JIVE_PIDS
if [ -n “${JIVE_PIDS}” ]; then
gprintf “%s (pid %s) is running…\n” “$” “$”

RETVAL=0

elif [ -f “$” ]; then

gprintf “%s dead but pid file exists\n” "$"
RETVAL=1
elif [ -f “$” ]; then
gprintf “%s dead but subsys locked\n” “$”

RETVAL=2

else

gprintf “%s is stopped\n” “$”

RETVAL=3

fi

return $RETVAL

}

case “$1” in

start)

start

;;

stop)

stop

;;

restart|reload)

restart

;;

status)

mdkstatus

;;

condrestart)

[ -f “$” ] && restart || :

;;

*)

gprintf “Usage: %s {start|stop|restart|status|condrestart}\n” “$0”

exit 1

esac

exit $?