chkconfig not starting application script on bootup

19,009

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)

Share:
19,009

Related videos on Youtube

gAMBOOKa
Author by

gAMBOOKa

Updated on September 18, 2022

Comments

  • gAMBOOKa
    gAMBOOKa almost 2 years

    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
    
  • gAMBOOKa
    gAMBOOKa over 12 years
    They're current showing up in /etc/rcx.d/S50myapp, and you're right, some services that are required load up after this. Like mysql is S62mysql. How can I change this sort order?
  • cjc
    cjc over 12 years
    Check the man page for chkconfig, the "RUNLEVEL FILES" section. Basically, the "# chkconfig 2345 85 60" line in your file. From that, it should be S85, which would start it after mysql. I guess you may have created the links prior to changing that line. In this case, I'd do "chkconfig --del myapp" to remove the links, and then "chkconfig --add myapp" to add them again. In the worst case, you can rename the symlinks in the /etc/rc?.d directories.
  • gAMBOOKa
    gAMBOOKa over 12 years
    chkconfig --del myapp does delete all the symlinks. But chkconfig --add myapp again sets them S60myapp. If I rename them manually, it might be an issue in the future if someone else decides to make changes to the script. I can't understand why it's being set to 50 when I'm clearly setting it to 85 60.
  • gAMBOOKa
    gAMBOOKa over 12 years
    That was it! Thanks cjc. Appreciate your patience with this!
  • Yuval
    Yuval over 10 years
    Thanks for the tip about the $PATH -- it lead me to check my init file, and it seems it was using a pid.lock file but not actually checking that the process was up, which caused a stale lock file preventing the daemon from starting. Thought it might help others if I mention this scenario.