diff --git a/docker-compose.yml b/docker-compose.yml index 3fbdacb..63e5d30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,12 +37,12 @@ services: - "80:80" - "443:443" volumes: - - "./configs/:/var/www/MISP/app/Config/" - - "./logs/:/var/www/MISP/app/tmp/logs/" - - "./files/:/var/www/MISP/app/files" - - "./ssl/:/etc/nginx/certs" + - "./configs/:/var/www/MISP/app/Config/:delegated" + - "./logs/:/var/www/MISP/app/tmp/logs/:delegated" + - "./files/:/var/www/MISP/app/files/:delegated" + - "./ssl/:/etc/nginx/certs/:delegated" # - "./examples/custom-entrypoint.sh:/custom-entrypoint.sh" # Use the example custom-entrypoint.sh - - "./.gnupg:/var/www/MISP/.gnupg" + - "./.gnupg/:/var/www/MISP/.gnupg/:delegated" environment: - "HOSTNAME=https://localhost" - "REDIS_FQDN=redis" diff --git a/server/files/entrypoint_cron.sh b/server/files/entrypoint_cron.sh index 8adb633..a59b51b 100755 --- a/server/files/entrypoint_cron.sh +++ b/server/files/entrypoint_cron.sh @@ -1,12 +1,14 @@ #!/bin/bash -term_pipe_procs() { - echo "Cron entrypoint caught SIGTERM signal!" +term_procs() { + echo "Entrypoint CRON caught SIGTERM signal!" + echo "Killing process $p1_pid" kill -TERM "$p1_pid" 2>/dev/null + echo "Killing process $p2_pid" kill -TERM "$p2_pid" 2>/dev/null } -trap term_pipe_procs SIGTERM +trap term_procs SIGTERM # Create the misp cron tab cat << EOF > /etc/cron.d/misp diff --git a/server/files/entrypoint_fpm.sh b/server/files/entrypoint_fpm.sh index 59661d7..d345705 100755 --- a/server/files/entrypoint_fpm.sh +++ b/server/files/entrypoint_fpm.sh @@ -1,8 +1,16 @@ #!/bin/bash -change_php_vars(){ +term_proc() { + echo "Entrypoint FPM caught SIGTERM signal!" + echo "Killing process $master_pid" + kill -TERM "$master_pid" 2>/dev/null +} + +trap term_proc SIGTERM + +change_php_vars() { for FILE in /etc/php/*/fpm/php.ini - do + do [[ -e $FILE ]] || break sed -i "s/memory_limit = .*/memory_limit = 2048M/" "$FILE" sed -i "s/max_execution_time = .*/max_execution_time = 300/" "$FILE" @@ -12,6 +20,9 @@ change_php_vars(){ } echo "Configure PHP | Change PHP values ..." && change_php_vars -echo "Starting PHP FPM" -/usr/sbin/php-fpm7.4 -R -F +echo "Starting PHP FPM" +/usr/sbin/php-fpm7.4 -R -F & master_pid=$! + +# Wait for it +wait "$master_pid" diff --git a/server/files/entrypoint_nginx.sh b/server/files/entrypoint_nginx.sh index 4127578..1c86e3e 100755 --- a/server/files/entrypoint_nginx.sh +++ b/server/files/entrypoint_nginx.sh @@ -1,5 +1,13 @@ #!/bin/bash +term_proc() { + echo "Entrypoint NGINX caught SIGTERM signal!" + echo "Killing process $master_pid" + kill -TERM "$master_pid" 2>/dev/null +} + +trap term_proc SIGTERM + MISP_APP_CONFIG_PATH=/var/www/MISP/app/Config [ -z "$MYSQL_HOST" ] && MYSQL_HOST=db [ -z "$MYSQL_PORT" ] && MYSQL_PORT=3306 @@ -150,7 +158,7 @@ echo "Configure MISP | Starting workers ..." && init_misp_workers # Work around https://github.com/MISP/MISP/issues/5608 if [[ ! -f /var/www/MISP/PyMISP/pymisp/data/describeTypes.json ]]; then mkdir -p /var/www/MISP/PyMISP/pymisp/data/ - ln -s /usr/local/lib/python3.7/dist-packages/pymisp/data/describeTypes.json /var/www/MISP/PyMISP/pymisp/data/describeTypes.json + ln -s /usr/local/lib/python3.9/dist-packages/pymisp/data/describeTypes.json /var/www/MISP/PyMISP/pymisp/data/describeTypes.json fi if [[ ! -L "/etc/nginx/sites-enabled/misp80" && "$NOREDIR" == true ]]; then @@ -232,10 +240,13 @@ if [[ -x /entrypoint_internal.sh ]]; then # export ${KEY}="${!KEY}" # done export MYSQLCMD=${MYSQLCMD} - nginx -g 'daemon on;' + nginx -g 'daemon off;' & master_pid=$! /entrypoint_internal.sh - killall nginx + kill -TERM "$master_pid" 2>/dev/null fi # Start NGINX -nginx -g 'daemon off;' +nginx -g 'daemon off;' & master_pid=$! + +# Wait for it +wait "$master_pid" diff --git a/server/files/etc/supervisor/supervisor.conf b/server/files/etc/supervisor/supervisor.conf index 0ed47f1..8b7c81f 100644 --- a/server/files/etc/supervisor/supervisor.conf +++ b/server/files/etc/supervisor/supervisor.conf @@ -14,6 +14,7 @@ password=supervisor [program:nginx] command=/entrypoint_nginx.sh autorestart=true +redirect_stderr=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr @@ -21,19 +22,18 @@ stderr_logfile_maxbytes=0 [program:php-fpm] command=/entrypoint_fpm.sh -process_name=%(program_name)s_%(process_num)02d -numprocs=1 -autostart=true -autorestart=false -startsecs=0 +autorestart=true +redirect_stderr=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:cron] +command=/entrypoint_cron.sh +autorestart=true redirect_stderr=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 - -[program:cron] -command=/entrypoint_cron.sh -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 -autostart=true