Install and configure supervisord on centos 7 to run Laravel queues permanently

后端 未结 3 2288
渐次进展
渐次进展 2020-12-07 17:50

I want to use Laravel queue system in my project and I want to run php artisan queue:work permanently on server\'s background, I did some searches about thi

3条回答
  •  情书的邮戳
    2020-12-07 18:28

    Hopefully this will be of use to someone, this is the process I have been through in addition to @Abdu's answer to get things working on CentOS 7.

    1. Install Supervisor

    easy_install supervisor

    * If not installed, run yum install -y python-setuptools and then easy_install supervisor

    2. Prep work

    To get the ideal setup running, you should run the following...

    # create directory for supervisor logs
    mkdir /var/log/supervisor
    
    # create directory for supervisor configs
    mkdir -p /etc/supervisor/conf.d
    
    # create config directory for supervisor
    cat <> /etc/supervisor/supervisord.conf
    ; supervisor config file
    
    [supervisord]
    logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
    pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
    childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
    
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
    
    [include]
    files = /etc/supervisor/conf.d/*.conf
    EOT
    
    # create systemctl service script
    cat <> /lib/systemd/system/supervisord.service
    [Unit]
    Description=Supervisor process control system for UNIX
    Documentation=http://supervisord.org
    After=network.target
    
    [Service]
    ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
    ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
    ExecReload=/usr/bin/supervisorctl -c /etc/supervisor/supervisord.conf $OPTIONS reload
    KillMode=process
    Restart=on-failure
    RestartSec=50s
    
    [Install]
    WantedBy=multi-user.target
    EOT
    

    Once you've done this, you should now be able to start and stop supervisor using systemctl. To start systemctl, run systemctl start supervisord. To view the status of supervisor, run systemctl status supervisord.

    You can create as many custom configurations as you like under /etc/supervisor/conf.d

    3. Enable on system startup

    You should also enable supervisord on startup by running

    systemctl enable supervisord
    

提交回复
热议问题