Skip to content

Commit

Permalink
Allows www-data to call horizon supervisorctl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradez committed Mar 7, 2024
1 parent 7bd2c22 commit 28bd305
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
5 changes: 2 additions & 3 deletions configs/core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ RUN cd laravel-application && \
RUN cd /app/laravel-application/vendor/gmajor/sr25519-bindings/go && go build -buildmode=c-shared -o sr25519.so . && mv sr25519.so ../src/Crypto/sr25519.so

# Stage: http setup

FROM create-application as http-setup

# Set ServerName to be localhost.
Expand All @@ -60,7 +59,7 @@ RUN dos2unix /var/www/html/.env

# Set permissions and ownership.
RUN chmod 777 -R /var/www/html/storage/
RUN chown -R www-data:www-data /var/www/
RUN chown -R www-data:www-data /var/www/ /var/log/supervisor

# Enable mod rewrite.
RUN update-rc.d supervisor defaults
Expand All @@ -71,7 +70,7 @@ COPY configs/core/apache/000-default.conf /etc/apache2/sites-available/000-defau

# Copy php configs.
COPY configs/core/php /usr/local/etc/php/conf.d
COPY configs/core/supervisor /etc/supervisor/conf.d
COPY configs/core/supervisor /etc/supervisor

# Stage: platform-core
FROM http-setup as enjin-platform
Expand Down
8 changes: 4 additions & 4 deletions configs/core/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ role=${CONTAINER_ROLE:-app}

if [ "$role" = "ingest" ]; then
echo "Running ingest..."
(php artisan cache:clear && php artisan config:cache && php artisan migrate && php artisan platform:sync && php artisan platform:ingest)
php artisan cache:clear && php artisan config:cache && php artisan migrate && php artisan platform:sync && php artisan platform:ingest
elif [ "$role" = "app" ]; then
echo "Caching configuration..."
chown -hR www-data:www-data /var/www/html/storage/logs || true
APP_KEY=$(awk '$1 ~ /^APP_KEY/' .env | cut -d "=" -f 2)
if [ -z "$APP_KEY" ]; then
php artisan key:generate
Expand All @@ -20,10 +19,11 @@ elif [ "$role" = "websocket" ]; then
echo "Running queue and websocket..."
chown -hR www-data:www-data /var/www/html/storage/logs || true
php artisan cache:clear && php artisan config:cache
supervisord -n --configuration /etc/supervisor/supervisord.conf
supervisord && supervisorctl start horizon
php artisan websockets:serve
elif [ "$role" = "beam" ]; then
echo "Running beam..."
(php artisan cache:clear && php artisan config:cache && php artisan platform:process-beam-claims)
php artisan cache:clear && php artisan config:cache && php artisan platform:process-beam-claims
else
echo "Could not match the container role \"$role\""
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[program:horizon]
process_name=%(program_name)s
command=/usr/local/bin/php /var/www/html/artisan horizon
autostart=true
autostart=false
autorestart=true
user=www-data
chown=www-data:www-data
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/horizon.log
stopwaitsecs=3600
stopwaitsecs=3600
30 changes: 30 additions & 0 deletions configs/core/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; supervisor config file

[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
user=www-data
chown=www-data:www-data

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket

; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf
10 changes: 0 additions & 10 deletions configs/core/supervisor/websockets.conf

This file was deleted.

0 comments on commit 28bd305

Please sign in to comment.