Working on CTRL+C and everything.

This commit is contained in:
Greyscale 2022-09-01 16:31:45 +02:00
parent bb78c0ad99
commit e501f50fbd
No known key found for this signature in database
GPG key ID: 74BAFF55434DA4B2
7 changed files with 32 additions and 74 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
.php-cs-fixer.cache
.idea
/vendor/
.minio
.minio
/test.yml

View file

@ -50,24 +50,17 @@ COPY sync-push.runit /etc/service/sync-push/run
VOLUME /dumps
WORKDIR /sync
COPY composer.* /sync/
RUN composer install
COPY syncer /sync/syncer
COPY sync /sync/sync
COPY start.sh /sync/start.sh
RUN composer install
ENV PATH="/sync:${PATH}"
RUN ln -s /sync/vendor/bin/wait-for-mariadb /usr/local/bin/wait-for-database && \
chmod +x /sync/sync /etc/service/*/run
ENTRYPOINT ["/bin/bash", "/sync/start.sh"]
CMD ["/bin/bash", "/sync/start.sh"]
ENTRYPOINT ["/sync/start.sh"]
CMD []
HEALTHCHECK --start-period=30s \
CMD /usr/local/bin/healthcheck.sh \
--defaults-extra-file=/etc/healthcheck.cnf \
--connect
FROM mariadb AS mariadb-traptest
COPY traptest.sh /usr/local/bin/traptest
#STOPSIGNAL SIGINT
RUN chmod +x /usr/local/bin/traptest
#CMD ["/usr/local/bin/traptest"]
ENTRYPOINT ["/usr/local/bin/traptest"]
#ENTRYPOINT []
STOPSIGNAL SIGTERM

View file

@ -54,22 +54,17 @@ COPY sync-push.runit /etc/service/sync-push/run
VOLUME /dumps
WORKDIR /sync
COPY composer.* /sync/
RUN composer install
COPY syncer /sync/syncer
COPY sync /sync/sync
COPY start.sh /sync/start.sh
COPY postgres_healthcheck.sh /usr/local/bin/postgres_healthcheck
RUN composer install
ENV PATH="/sync:${PATH}"
RUN ln -s /sync/vendor/bin/wait-for-postgresql /usr/local/bin/wait-for-database && \
chmod +x /sync/sync /etc/service/*/run /usr/local/bin/postgres_healthcheck
ENTRYPOINT ["/bin/bash", "/sync/start.sh"]
STOPSIGNAL SIGINT
CMD ["/bin/bash", "/sync/start.sh"]
CMD []
HEALTHCHECK --start-period=30s \
CMD /usr/local/bin/postgres_healthcheck
STOPSIGNAL SIGTERM
FROM postgres AS postgres-traptest
COPY traptest.sh /usr/local/bin/traptest
RUN chmod +x /usr/local/bin/traptest
CMD []
ENTRYPOINT ["/usr/local/bin/traptest"]

6
Dockerfile.traptest Normal file
View file

@ -0,0 +1,6 @@
FROM ubuntu:jammy AS mariadb-traptest
COPY traptest.sh /usr/local/bin/traptest
RUN chmod +x /usr/local/bin/traptest
ENTRYPOINT ["/usr/local/bin/traptest"]
CMD []
STOPSIGNAL SIGINT

View file

@ -26,6 +26,7 @@ services:
build:
context: .
dockerfile: Dockerfile.postgres
target: postgres
args:
PGSQL_VERSION: 14
environment:
@ -49,6 +50,7 @@ services:
build:
context: .
dockerfile: Dockerfile.mariadb
target: mariadb
args:
MARIADB_VERSION: 10.9
environment: &mariadb
@ -74,6 +76,7 @@ services:
build:
context: .
dockerfile: Dockerfile.mariadb
target: mariadb
args:
MARIADB_VERSION: 10.3
environment:

View file

@ -8,16 +8,20 @@ chmod +x /etc/service/*/run
# Define shutdown + cleanup procedure
cleanup() {
echo ""
echo "SIGTERM called!"
echo "Container stop requested, running final dump + cleanup"
/sync/sync --push
echo "Good bye!"
exit 0
}
# Trap SIGTERM
echo "Setting SIGTERM trap"
trap 'cleanup' EXIT SIGINT
trap 'echo SIGQUIT' SIGQUIT
trap 'cleanup' SIGTERM
# Start Runit.
echo "Starting Runit."
runsvdir -P /etc/service
exec runsvdir -P /etc/service &
sleep infinity & wait

View file

@ -1,55 +1,11 @@
#!/bin/bash
# traptest.sh
# Define shutdown + cleanup procedure
cleanup() {
echo "Container stop requested, running final dump + cleanup"
echo "Good bye!"
}
# Trap SIGTERM
echo "Setting SIGTERM trap"
trap 'cleanup' EXIT SIGINT
trap 'echo SIGQUIT' SIGQUIT
trap 'echo "Caught EXIT"' EXIT
trap 'echo "Caught SIGINT"' SIGINT
trap 'echo "Caught SIGTERM"' SIGTERM
trap 'echo "Caught SIGKILL"' SIGKILL
trap 'echo "Caught SIGQUIT"' SIGQUIT
# Trap SIGTERM
#echo "Setting SIGTERM trap"
#trap 'echo "Hello!"' SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGIO SIGPIPE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTKFLT SIGSTOP SIGTSTP SIGSYS SIGTERM SIGTRAP SIGTTIN SIGTTOU SIGURG SIGUSR1 SIGUSR2 SIGVTALRM SIGXCPU SIGXFSZ SIGWINCH
#trap 'cleanup' EXIT
#trap 'echo SIGABRT' SIGABRT
#trap 'echo SIGALRM' SIGALRM
#trap 'echo SIGBUS' SIGBUS
#trap 'echo SIGCHLD' SIGCHLD
#trap 'echo SIGCONT' SIGCONT
#trap 'echo SIGFPE' SIGFPE
#trap 'echo SIGHUP' SIGHUP
#trap 'echo SIGILL' SIGILL
#trap 'echo SIGINT' SIGINT
#trap 'echo SIGIO' SIGIO
#trap 'echo SIGPIPE' SIGPIPE
#trap 'echo SIGPROF' SIGPROF
#trap 'echo SIGPWR' SIGPWR
#trap 'echo SIGQUIT' SIGQUIT
#trap 'echo SIGSEGV' SIGSEGV
#trap 'echo SIGSTKFLT' SIGSTKFLT
#trap 'echo SIGSTOP' SIGSTOP
#trap 'echo SIGTSTP' SIGTSTP
#trap 'echo SIGSYS' SIGSYS
#trap 'echo SIGTERM' SIGTERM
#trap 'echo SIGTRAP' SIGTRAP
#trap 'echo SIGTTIN' SIGTTIN
#trap 'echo SIGTTOU' SIGTTOU
#trap 'echo SIGURG' SIGURG
#trap 'echo SIGUSR1' SIGUSR1
#trap 'echo SIGUSR2' SIGUSR2
#trap 'echo SIGVTALRM' SIGVTALRM
#trap 'echo SIGXCPU' SIGXCPU
#trap 'echo SIGXFSZ' SIGXFSZ
#trap 'echo SIGWINCH' SIGWINCH
echo "pid is $$"
while : # This is the same as "while true".
do
echo "Idling"
sleep 60 # This script is not really doing anything.
done
echo "Sleeping 600 seconds."
sleep 600 & wait