forked from scriptoshi/memex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue-worker-setup-fedora.sh
More file actions
66 lines (54 loc) · 1.58 KB
/
queue-worker-setup-fedora.sh
File metadata and controls
66 lines (54 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
if [ ! -f "./artisan" ]; then
echo "Error: Run from Laravel project root"
exit 1
fi
ARTISAN_PATH=$(readlink -f ./artisan)
PROJECT_DIR=$(basename $(pwd))
SAFE_PROJECT_NAME=$(echo "$PROJECT_DIR" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
if [ "$EUID" -ne 0 ]; then
echo "Run with sudo"
exit 1
fi
# Fedora-specific package installation
dnf install -y supervisor
systemctl enable supervisord
systemctl start supervisord
# Configure supervisord
cat > /etc/supervisord.d/supervisord.conf << EOF
[supervisord]
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor
minfds=10000
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0700
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
[include]
files = /etc/supervisord.d/*.ini
EOF
# Create queue worker config
cat > "/etc/supervisord.d/laravel-queue-${SAFE_PROJECT_NAME}.ini" << EOF
[program:laravel-queue-${SAFE_PROJECT_NAME}]
process_name=%(program_name)s_%(process_num)02d
command=php ${ARTISAN_PATH} queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=nobody
numprocs=2
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-queue-${SAFE_PROJECT_NAME}.log
stopwaitsecs=3600
EOF
mkdir -p /var/log/supervisor
chown -R nobody:nobody /var/log/supervisor
supervisorctl reread
supervisorctl update
supervisorctl start "laravel-queue-${SAFE_PROJECT_NAME}:*"
supervisorctl status