Supervisord “exit status 1 not expected” running php script

前端 未结 3 1618
长情又很酷
长情又很酷 2021-01-12 04:16

I\'m having issue try to configure supervisor to run a php script. Running supervisor in debug mode gives me this:

2015-03-09 08:53:06,342 INFO supervisord s         


        
相关标签:
3条回答
  • 2021-01-12 05:05

    The only way I could reproduce this behaviour with exit code 1 is to use a invalid path to the file. So first please double check if the path is correct. But I think you have done this before.

    I more assume that the file is located under your home directory and the root user is not able access and run it. So I would try to change the location of the script.

    For testing, you can place your script under /tmp/myScript.php:

    cp /home/path/to/script/myScript.php /tmp/myScript.php
    

    and modify your supervisord config like this:

    [program:worker1]
    command=php myScript.php
    directory=/tmp/
    user=root
    autostart=true
    autorestart=true
    stderr_logfile=/var/log/worker1.err.log
    stdout_logfile=/var/log/worker1.out.log
    redirect_stderr=true
    environment=PATH="/usr/bin"
    

    Now supervisored should be able to run your script.

    If this is working, you should check which folder prevent root from accessing the script. This could be caused by an encypted (and mounted) folder (home dir?), or if the location is mounted from else where (samba, nfs ...). To solve the issue you can try to change the user from root to your user (I would not recommend this) or change the project location to another folder, which is not located under your home dir.

    0 讨论(0)
  • 2021-01-12 05:09

    I've been using Supervisord for a while and this is what I have in my config:

    [program:worker1]
    command=php /absolute/path/to/myScript.php
    

    Reason I'm writing this as an anwser is due to formatting.

    Also, try this script:

    for(i = 0; i < 10; i++)
    {
        printf("\nIteration: %d", $i);
        usleep(1000 * 200); // 200 milliseconds between each printf
    }
    
    exit;
    

    And add it to supervision. It should be restarted after it does its echoing.

    0 讨论(0)
  • 2021-01-12 05:14

    Try to set startsecs = 0:

    [program:foo]
    command = ls
    startsecs = 0
    autorestart = false
    http://supervisord.org/configuration.html
    

    startsecs

    The total number of seconds which the program needs to stay running after a startup to consider the start successful. If the program does not stay up for this many seconds after it has started, even if it exits with an “expected” exit code (see exitcodes), the startup will be considered a failure. Set to 0 to indicate that the program needn’t stay running for any particular amount of time.

    0 讨论(0)
提交回复
热议问题