Zainstaluj i skonfiguruj supervisord na centos 7, aby na stałe uruchamiać kolejki Laravel

Chcę użyć systemu kolejki Laravel w moim projekcie i chcę uruchomić php artisan queue: work na stałe w tle serwera, przeszukałem to i znalazłem wiersz poleceń, który może go uruchomić nawet po wyjściu z terminala ssh, ale w niektórych przypadkach może być wyłączony i może sprawiać straszne problemy. Tak więc po jakimś czasie dowiedziałem się, że istnieje pakiet o nazwie Supervisord, który może ponownie uruchomić polecenie nawet po ponownym uruchomieniu serwera. Więc chcę kogoś poprosić o pomoc od 0 do 100 krok po kroku jak zainstalować i skonfigurować go na centos 7 a potem ustawić wiersz poleceń queue. Dziękuję bardzo..

Author: Tohid Dadashnezhad, 2017-07-20

3 answers

Oto jak zainstalować i skonfigurować na centos 7 aby uruchamiać kolejki Laravel na stałe:

  1. easy_install supervisor
  2. yum install supervisor
  3. vim /etc/supervisord.conf edycja programu sekcji w następujący sposób:
[program:laravel-worker]
command=php /path/to/app.com/artisan queue:work 
process_name=%(program_name)s_%(process_num)02d
numprocs=8 
priority=999 
autostart=true
autorestart=true  
startsecs=1
startretries=3
user=apache
redirect_stderr=true
stdout_logfile=/path/to/log/worker.log
  1. systemctl enable supervisord to autorun at start
  2. systemctl restart supervisord aby ponownie uruchomić usługę
 67
Author: Abdu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-11-16 12:02:16

Mam nadzieję, że to się komuś przyda, to jest proces, przez który przeszedłem oprócz odpowiedzi @Abdu, aby wszystko działało na CentOS 7.

1. Install Supervisor

easy_install supervisor

* jeśli nie jest zainstalowany, uruchom yum install -y python-setuptools a następnie easy_install supervisor

2. Praca przygotowawcza

Aby uruchomić idealną konfigurację, należy uruchomić następujące czynności...

# 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 <<EOT >> /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 <<EOT >> /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

Gdy już to zrobisz, powinieneś być w stanie uruchomić i zatrzymać nadzorcę za pomocą systemctl. Na Uruchom systemctl, Uruchom systemctl start supervisord. Aby wyświetlić status nadzorcy, Uruchom systemctl status supervisord.

Możesz utworzyć dowolną liczbę niestandardowych konfiguracji Pod /etc/supervisor/conf.d

3. Włącz przy starcie systemu

Należy również włączyć supervisord przy starcie, uruchamiając

systemctl enable supervisord
 12
Author: Chris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-07-23 11:10:27

Na moim koncie Bluehost systemctl nie był uruchomiony, ale zamiast tego chkserv był używany do monitorowania i ponownego uruchamiania procesów, więc dwie odpowiedzi tutaj nie w pełni działają dla mnie.

Również napotkałem błąd z easy_install supervisor, ponieważ próbował zainstalować nowy 4.wersja x.X, która wymaga Python > 2.6, podczas gdy 2.6 była dokładną wersją Pythona działającą na moim komputerze.

Oto, co dla mnie zadziałało:

  1. yum install -y python-setuptools

  2. easy_install supervisor==3.4.0

  3. nano /etc/supervisord.conf oraz dodaj

[supervisord]
nodaemon=true

[include]
files = /etc/supervisor/conf.d/*.conf

[program:laravel-worker]
command=php artisan queue:work --tries=1
autostart=true
autorestart=true
stderr_logfile=/var/log/queue.err.log
stdout_logfile=/var/log/queue.out.log
  1. nano /etc/chkserv.d/chkservd.conf, Dodaj linię supervisord:1, a następnie zapisz plik

  2. touch /etc/chkserv.d/supervisord aby utworzyć plik konfiguracyjny chkservd

  3. nano /etc/chkserv.d/supervisord, dodaj linię service[supervisord]=x,x,x,service supervisord restart,supervisord,root, a następnie zapisz plik

  4. supervisord pojawi się teraz w WHM Pod Service Manager, a chkservd uruchomi go i upewni się, że działa, ale aby ręcznie uruchomić, po prostu uruchom supervisord

Aby uzyskać więcej informacji na temat dodawania usługi do chkservd, klik tutaj .

 1
Author: kregus,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-08-20 13:55:17