Fix entrypoints and improve disk performance (#10)

Co-authored-by: Stefano Ortolani <ortolanis@vmware.com>
pull/1/head
Stefano Ortolani 2022-11-30 16:42:16 +00:00 committed by GitHub
parent 231d099a9f
commit 212a9ca557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 27 deletions

View File

@ -37,12 +37,12 @@ services:
- "80:80" - "80:80"
- "443:443" - "443:443"
volumes: volumes:
- "./configs/:/var/www/MISP/app/Config/" - "./configs/:/var/www/MISP/app/Config/:delegated"
- "./logs/:/var/www/MISP/app/tmp/logs/" - "./logs/:/var/www/MISP/app/tmp/logs/:delegated"
- "./files/:/var/www/MISP/app/files" - "./files/:/var/www/MISP/app/files/:delegated"
- "./ssl/:/etc/nginx/certs" - "./ssl/:/etc/nginx/certs/:delegated"
# - "./examples/custom-entrypoint.sh:/custom-entrypoint.sh" # Use the example custom-entrypoint.sh # - "./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: environment:
- "HOSTNAME=https://localhost" - "HOSTNAME=https://localhost"
- "REDIS_FQDN=redis" - "REDIS_FQDN=redis"

View File

@ -1,12 +1,14 @@
#!/bin/bash #!/bin/bash
term_pipe_procs() { term_procs() {
echo "Cron entrypoint caught SIGTERM signal!" echo "Entrypoint CRON caught SIGTERM signal!"
echo "Killing process $p1_pid"
kill -TERM "$p1_pid" 2>/dev/null kill -TERM "$p1_pid" 2>/dev/null
echo "Killing process $p2_pid"
kill -TERM "$p2_pid" 2>/dev/null kill -TERM "$p2_pid" 2>/dev/null
} }
trap term_pipe_procs SIGTERM trap term_procs SIGTERM
# Create the misp cron tab # Create the misp cron tab
cat << EOF > /etc/cron.d/misp cat << EOF > /etc/cron.d/misp

View File

@ -1,5 +1,13 @@
#!/bin/bash #!/bin/bash
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() { change_php_vars() {
for FILE in /etc/php/*/fpm/php.ini for FILE in /etc/php/*/fpm/php.ini
do do
@ -12,6 +20,9 @@ change_php_vars(){
} }
echo "Configure PHP | Change PHP values ..." && 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"

View File

@ -1,5 +1,13 @@
#!/bin/bash #!/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 MISP_APP_CONFIG_PATH=/var/www/MISP/app/Config
[ -z "$MYSQL_HOST" ] && MYSQL_HOST=db [ -z "$MYSQL_HOST" ] && MYSQL_HOST=db
[ -z "$MYSQL_PORT" ] && MYSQL_PORT=3306 [ -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 # Work around https://github.com/MISP/MISP/issues/5608
if [[ ! -f /var/www/MISP/PyMISP/pymisp/data/describeTypes.json ]]; then if [[ ! -f /var/www/MISP/PyMISP/pymisp/data/describeTypes.json ]]; then
mkdir -p /var/www/MISP/PyMISP/pymisp/data/ 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 fi
if [[ ! -L "/etc/nginx/sites-enabled/misp80" && "$NOREDIR" == true ]]; then if [[ ! -L "/etc/nginx/sites-enabled/misp80" && "$NOREDIR" == true ]]; then
@ -232,10 +240,13 @@ if [[ -x /entrypoint_internal.sh ]]; then
# export ${KEY}="${!KEY}" # export ${KEY}="${!KEY}"
# done # done
export MYSQLCMD=${MYSQLCMD} export MYSQLCMD=${MYSQLCMD}
nginx -g 'daemon on;' nginx -g 'daemon off;' & master_pid=$!
/entrypoint_internal.sh /entrypoint_internal.sh
killall nginx kill -TERM "$master_pid" 2>/dev/null
fi fi
# Start NGINX # Start NGINX
nginx -g 'daemon off;' nginx -g 'daemon off;' & master_pid=$!
# Wait for it
wait "$master_pid"

View File

@ -14,6 +14,7 @@ password=supervisor
[program:nginx] [program:nginx]
command=/entrypoint_nginx.sh command=/entrypoint_nginx.sh
autorestart=true autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr stderr_logfile=/dev/stderr
@ -21,19 +22,18 @@ stderr_logfile_maxbytes=0
[program:php-fpm] [program:php-fpm]
command=/entrypoint_fpm.sh command=/entrypoint_fpm.sh
process_name=%(program_name)s_%(process_num)02d autorestart=true
numprocs=1 redirect_stderr=true
autostart=true stdout_logfile=/dev/stdout
autorestart=false stdout_logfile_maxbytes=0
startsecs=0 stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:cron]
command=/entrypoint_cron.sh
autorestart=true
redirect_stderr=true redirect_stderr=true
stdout_logfile=/dev/stdout stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
[program:cron]
command=/entrypoint_cron.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0
autostart=true