LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-29-2013, 11:32 AM   #1
sarahlizy
LQ Newbie
 
Registered: Apr 2013
Posts: 5

Rep: Reputation: Disabled
Question Service won't start on boot


Hi,

In a server running Red Hat 4.4.6-3 I've been trying to set up a script to launch some java workers whenever the system reboots. I set up chkconfig so that the my script is a service and should be the last thing to boot (except rc.local):
# chkconfig: 2345 98 98
And my logs show that it does try to launch but fails (the logs I've managed to get don't say why). I've also had the same issue in other servers with jboss and tomcat. Thinking that java was the only thing these all have in common I sourced java in my startup script:
JAVA_HOME=/usr/java/jdk1.6.0_13
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

But the service still won't run. Previously in a different server running a different os the processes were run on boot so I know it should be possible. Can anyone suggest something I can try?
 
Old 04-29-2013, 01:32 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by sarahlizy View Post
Can anyone suggest something I can try?
Yeah:
- post the actual name of the application you're trying to start,
- post the complete service script you're using,
- try to make the application emit more verbose or debug nfo through the use of switches (see manual page or documentation).
 
Old 04-29-2013, 01:49 PM   #3
sarahlizy
LQ Newbie
 
Registered: Apr 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
its a custom built application so its name is kind of irrelevant but like I say jboss and tomcat have the same issue.

This is my current version of the script as you can see I've already upped the logging to be pretty verbose but there's still no clue given to why the app cant start successfully.
Code:
#!/bin/bash
#
# chkconfig: 2345 98 98
# description: app control script
#
#
#

JAVA_HOME=/usr/java/jdk1.6.0_13
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

# Source function library.
. /etc/init.d/functions

DIR="/opt/sarahlizy/app"
TODAY=$(date +"%Y%m%d")
FILE="appstartup_$TODAY.log"

case "$1" in
  start)
    echo "start option chosen"  >> /var/log/$FILE
    echo "launching workers " >> /var/log/$FILE

    sudo su - sarahlizy $DIR/launch-workers.sh >> /var/log/$FILE
    RETVAL=$? >> /var/log/$FILE
    [ $RETVAL -eq 0 ] && echo Success >> /var/log/$FILE
    [ $RETVAL -ne 0 ] && echo Failure >> /var/log/$FILE
    ;;
  stop)
    echo "stop option chosen"  >> /var/log/$FILE
    echo "Stopping workers"  >> /var/log/$FILE
    sudo su - sarahlizy $DIR/stop-workers.sh  >> /var/log/$FILE
    ;;
  restart)
    echo "restart option chosen"  >> /var/log/$FILE
    echo "Stopping workers" >> /var/log/$FILE
    sudo su - sarahlizy $DIR/stop-workers.sh >> /var/log/$FILE
    echo "launching workers " >> /var/log/$FILE
    sudo su - sarahlizy $DIR/launch-workers.sh >> /var/log/$FILE
    ;;
  status)
    echo "status option chosen"  >> /var/log/$FILE >> /var/log/$FILE
    state= jps -lm >> /var/log/$FILE
    echo $state >> /var/log/$FILE
    ;;
  *)
    echo "Usage: /etc/init.d/app {start|stop|restart|status}"
    exit 1
    ;;
esac
 
Old 04-29-2013, 01:53 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
So what does "$DIR/launch-workers.sh" contain?
Is "state= jps -lm" (args w/o quotes) really a BASH-compliant line?
 
Old 04-29-2013, 02:12 PM   #5
sarahlizy
LQ Newbie
 
Registered: Apr 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
its just a bunch of lines like:
/usr/bin/nohup $DIR/app/bin/worker1 &>/dev/null &

The problem isn't really with the script as the scrips work fine when you use them as a service (and work in other linux os's on boot) it's that the service doesn't successfully start on a bootup so I assume there's something that redhat does differently on startup.

Yeah "state= jps -lm" is bash compliant, it runs assigns the result of "jps -lm" to the variable "state" and then when you "echo $state" it prints the result correctly
 
Old 04-29-2013, 11:53 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by sarahlizy View Post
its just a bunch of lines like:
/usr/bin/nohup $DIR/app/bin/worker1 &>/dev/null &
Like I said, to make the application emit more verbose or debug nfo you have to assess each part of your command chain until you find the part that takes "--verbose" "--debug" or equivalent switches, so don't dump any output into the bit bucket. And Tomcat and Java-based applications often reference log configuration in their own configuration files so check those as well.


Quote:
Originally Posted by sarahlizy View Post
The problem isn't really with the script as the scrips work fine when you use them as a service (and work in other linux os's on boot) it's that the service doesn't successfully start on a bootup so I assume there's something that redhat does differently on startup.
I'm not in favor of assuming things. Checking stdout / stderr and log file contents (and if the audit service is available and running also see /var/log/audit) would be my first reflex.
 
Old 05-02-2013, 09:46 AM   #7
sarahlizy
LQ Newbie
 
Registered: Apr 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Unfortunately even at the highest level of logging the applicationitself never runs for long enough to log anything (assuming it runs at all, which I suspect it doesn't). I managed to log some lines from the script which loads the workers but all they log is info about finding the app logging settings then the logging stops. There doesn't appear to be anything that points me towards a solution in /var/log/audit either. This may just be something that remains a mystery.
 
Old 05-21-2013, 10:40 AM   #8
sarahlizy
LQ Newbie
 
Registered: Apr 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Smile Solved

I found this today: https://github.com/hectcastro/chef-statsd/issues/10

Inside my startup script I was using sudo to launch my java process but if the line "Defaults requiretty" is uncommented in /etc/sudoers then sudo isn't allowed on boot. I tested the theory by commenting out that line and doing a reboot and sure enough my process started. I'm now using "daemon --user=myuser myapp" to launch my app instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
service won't start at boot jgonsalves Linux - Newbie 9 05-26-2010 08:42 AM
rdisc service won't start...PLEASE HELP!!!! wesley.bruwer Linux - Networking 2 12-12-2008 12:09 AM
httpd service won't start GavB Linux - Newbie 4 01-19-2007 07:56 AM
named service won't start? a2vr6 Linux - Newbie 10 09-04-2006 04:20 AM
Named service won't start DanielTan Fedora - Installation 2 09-28-2005 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration