Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docker/conf/supervisor/example/queue.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[program:laravel-queue-$QUEUE_DOMAIN]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --domain=$QUEUE_DOMAIN --queue=default,broadcast,video --sleep=3 --tries=3 --timeout=600
#user=devilbox
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stopwaitsecs=3600
#logfile=/etc/supervisor/conf.d/horizon.log


stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stdout_events_enabled = true

stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
stderr_events_enabled = true
66 changes: 38 additions & 28 deletions init_multidomains.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/bin/bash

echo "Wellms multidomains init script!"
echo "Wellms multidomains init script!"

if [ "$DISABLE_PHP_FPM" == 'true' ]
then
rm -f /etc/supervisor/conf.d/php-fpm.conf
echo php-fpm.conf disabled
else
else
cp docker/conf/supervisor/services/php-fpm.conf /etc/supervisor/conf.d/php-fpm.conf
echo php-fpm.conf enabled
fi

if [ "$DISABLE_QUEUE" == 'true' ]
then
rm -f /etc/supervisor/custom.d/multidomain_queue.conf
echo multidomain_queue.conf disabled
else
cp docker/conf/supervisor/services/multidomain_queue.conf /etc/supervisor/custom.d/multidomain_queue.conf
echo multidomain_queue.conf enabled
fi
#if [ "$DISABLE_QUEUE" == 'true' ]
#then
# rm -f /etc/supervisor/custom.d/multidomain_queue.conf
# echo multidomain_queue.conf disabled
#else
# cp docker/conf/supervisor/services/multidomain_queue.conf /etc/supervisor/custom.d/multidomain_queue.conf
# echo multidomain_queue.conf enabled
#fi

if [ "$DISABLE_BROADCAST" == 'true' ]
then
Expand All @@ -37,8 +37,8 @@
rm -f /etc/supervisor/custom.d/scheduler.conf

# set env from `LARAVEL_` prefixed env vars
# this also setup MULTI_DOMAINS eg
# when MULTI_DOMAINS: "api-sprawnymarketing.escolalms.com,api-gest.escolalms.com"
# this also setup MULTI_DOMAINS eg
# when MULTI_DOMAINS: "api-sprawnymarketing.escolalms.com,api-gest.escolalms.com"
# then API_SPRAWNYMARKETING_ESCOLALMS_COM_APP_NAME: '"Sprawny Marketing"'

# if binded by k8s or docker those folders might need to be recreated
Expand All @@ -50,10 +50,10 @@
if [ ! -d "storage/app" ]; then mkdir storage/app; fi
if [ ! -d "storage/logs" ]; then mkdir storage/logs; fi

# generate general .env file for next specific domain files
# generate general .env file for next specific domain files
# as `php artisan domain:add $domain` copy values from `.env`
echo "Generating general .env file for next specific domain files"
php docker/envs/envs.php
php docker/envs/envs.php

# if binded by k8s or docker those folders might need to be recreated
mkdir storage
Expand Down Expand Up @@ -84,6 +84,16 @@
else
echo "Schedule disabled"
fi

if [ -z "$DISABLE_QUEUE" ] || [ "$DISABLE_QUEUE" != "true" ];

Check failure on line 88 in init_multidomains.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=EscolaLMS_API&issues=AZ29-WGStKVg6UfIU3Tr&open=AZ29-WGStKVg6UfIU3Tr&pullRequest=431

Check failure on line 88 in init_multidomains.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=EscolaLMS_API&issues=AZ29-WGStKVg6UfIU3Tq&open=AZ29-WGStKVg6UfIU3Tq&pullRequest=431
then
cp "docker/conf/supervisor/example/queue.conf.example" "/etc/supervisor/custom.d/queue.$domain.conf"
sed "s/\$QUEUE_DOMAIN/$domain/g" "docker/conf/supervisor/example/queue.conf.example" > "/etc/supervisor/custom.d/queue.$domain.conf"
echo "Queue for $domain enabled"
else
echo "Queue for $domain disabled"
fi

# delare variables
DOMAIN_KEY=$(echo "$domain" | tr '[:lower:]' '[:upper:]')
DOMAIN_KEY=$(echo "$DOMAIN_KEY" | tr '.-' '__')
Expand All @@ -95,7 +105,7 @@

php docker/envs/envs_multidomains.php $domain $DOMAIN_KEY

# create keys from env base64 variables
# create keys from env base64 variables
if [ -n "$JWT_PUBLIC_KEY_BASE64" ]; then
echo "Storing public shared env JWT_PUBLIC_KEY_BASE64 RSA key for JWT generation - /var/www/html/storage/${STORAGE_DIRECTORY}/oauth-public.key"
echo ${JWT_PUBLIC_KEY_BASE64} | base64 -d > /var/www/html/storage/${STORAGE_DIRECTORY}/oauth-public.key
Expand All @@ -117,8 +127,8 @@
echo ${!SPECIFIC_JWT_PRIVATE_KEY_BASE64} | base64 -d > /var/www/html/storage/${STORAGE_DIRECTORY}/oauth-private.key
fi



# db migrate
if [ "$DISABLE_DB_MIGRATE" == 'true' ]
then
Expand All @@ -128,11 +138,11 @@
fi

# generate passport keys only if storage/oauth-private.key is not set
# note that app:keys are generated here as well
# note that app:keys are generated here as well
FILE=storage/${STORAGE_DIRECTORY}/oauth-private.key
if [ -f "$FILE" ]; then
echo "key file $FILE exists. Using one from file or env"
else
echo "key file $FILE exists. Using one from file or env"
else
echo "$FILE does not exist. Generating app keys, passport keys and passport client"
php artisan key:generate --force --no-interaction --domain=$domain
php artisan passport:keys --force --no-interaction --domain=$domain
Expand All @@ -153,16 +163,16 @@
else
php artisan h5p:storage-link --overwrite --domain=$domain
fi


done
else
echo "Environment variable MULTI_DOMAINS is empty."
fi

# Default setup
# Default setup
echo "Default setup"
# This is required for create default laravel envs
# This is required for create default laravel envs
if [ -n "$JWT_PUBLIC_KEY_BASE64" ]; then
echo "Storing public RSA key for JWT generation - storage/oauth-public.key"
echo ${JWT_PUBLIC_KEY_BASE64} | base64 -d > storage/oauth-public.key
Expand All @@ -177,26 +187,26 @@
if [ "$DISABLE_DB_MIGRATE" == 'true' ]
then
echo "Disable db migrate"
else
else
php artisan migrate --force
fi

# generate passport keys only if storage/oauth-private.key is not set

FILE=storage/oauth-private.key
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "$FILE exists."
else
echo "$FILE does not exist. Generating app keys, passport keys and passport client"
#php artisan key:generate --force --no-interaction
php artisan passport:keys --force --no-interaction
php artisan passport:keys --force --no-interaction
#php artisan passport:client --personal --no-interaction
fi

touch inited

# TODO: Fixme
# This is required so far as docker compose run this script as root
# This is required so far as docker compose run this script as root

chown -R www-data:www-data /var/www/html/storage

Expand Down
Loading