OS: Centos 5.7
My application script starts like this (/etc/init.d/myapp):
#!/bin/sh
# chkconfig 2345 85 60
# description: my application controller
# processname: myapp
NAME=MyApp
DIR=/opt/myapp/
RUN_AS=root
### BEGIN INIT INFO
# Provides: myapp
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts the myapp application
### END INIT INFO
Chkconfig status
chkconfig --list | grep myapp
myapp 0:off 1:off 2:on 3:on 4:on 5:on 6:off
myapp accepts start | stop | restart | force-reload and they're all tested to work
myapp controller basically needs to start some daemon services for the application. If I run service myapp start
after the system is rebooted, everything works fine. But for some reason, chkconfig is not starting it up automatically. Can anyone explain what I may be doing wrong?
UPDATE:
Thanks to cjc's information, it appears that my application controller is loading prior to some required services such as mysql.
Here's the result of a quick search:
find /etc -name rc* -type d | xargs ls | grep myapp
K50myapp
K50myapp
S50myapp
S50myapp
S50myapp
S50myapp
K50myapp
So why is the order set to 50 when in the script I've set to 85(start) 60(stop)? And how can I change this?
Solution (as pointed out by cjc in comments to his answer)
Incorrect syntax:
# chkconfig 2345 85 60
Correct to (colon needed after chkconfig):
# chkconfig: 2345 85 60
chkconfig essentially makes a symlink from, say, /etc/rc3.d/S85myapp to /etc/init.d/myapp. Verify that those links exist. I assume they do, since the "chkconfig --list" is showing that they're "on".
Since you can execute /etc/init.d/myapp from prompt, but it doesn't occur during startup, my guess is that there's an issue with the PATH, or that a service that you need up and running before executing myapp is actually initializing after myapp. Remember that the scripts in /etc/rc3.d (or whatever your initial runlevel is) are executed in sort order. Verify that myapp has everything it needs to run.
(My guess it that there's a PATH issue, though)