According to this code, there should be a graceful shutdown on SIGTERM, and "shutting down..." should appear in the log.
|
// Wait for signal to initiate server shutdown. |
|
quit := make(chan os.Signal) |
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1) |
|
|
|
sig := <-quit |
|
|
|
// Stop all background activity. |
|
auto.Shutdown() |
|
workers.Shutdown() |
|
session.Shutdown() |
|
mutex.CancelAll() |
|
|
|
log.Info("shutting down...") |
|
cancel() |
|
|
|
if contextErr := dctx.Release(); contextErr != nil { |
|
log.Error(contextErr) |
|
} |
|
|
|
// Finally, close the DB connection after a short grace period. |
|
time.Sleep(2 * time.Second) |
|
conf.Shutdown() |
|
|
|
// Don't exit with 0 if SIGUSR1 was received to avoid restarts. |
|
if sig == syscall.SIGUSR1 { |
|
os.Exit(1) |
|
return nil |
|
} |
|
|
|
return nil |
Docker sends SIGTERM to the entrypoint process, but the process exits immediately with code 143, without any further log output.
One of the issues this causes is the unix socket is not removed on shutdown (#4673 (comment)). It might cause other issues as well.
I reproduced it with fresh Multipass VM with Ubuntu 24.04.1 (launch with more than 5gib disk). I installed docker with sudo apt install docker.io docker-compose. Docker version is 26.1.3. I used the official compose file from the documentation:
wget https://dl.photoprism.app/docker/compose.yaml
Without making any changes, I run it with docker-compose up -d, and it runs normally.

Then I stop server with docker-compose stop photoprism.
In docker-compose logs photoprism, nothing is logged on shutdown.
In docker inspect photoprism_photoprism_1, the exit status is 143.

According to this code, the exit status should be 1:
|
// Don't exit with 0 if SIGUSR1 was received to avoid restarts. |
|
if sig == syscall.SIGUSR1 { |
|
os.Exit(1) |
|
return nil |
|
} |
because the docker entrypoint script traps SIGTERM and sends SIGUSR1 to photoprism:
|
trap "kill -USR1 $PID" INT TERM |
According to this code, there should be a graceful shutdown on SIGTERM, and "shutting down..." should appear in the log.
photoprism/internal/commands/start.go
Lines 144 to 173 in e1280b2
Docker sends SIGTERM to the entrypoint process, but the process exits immediately with code 143, without any further log output.
One of the issues this causes is the unix socket is not removed on shutdown (#4673 (comment)). It might cause other issues as well.
I reproduced it with fresh Multipass VM with Ubuntu 24.04.1 (launch with more than 5gib disk). I installed docker with
sudo apt install docker.io docker-compose. Docker version is 26.1.3. I used the official compose file from the documentation:Without making any changes, I run it with
docker-compose up -d, and it runs normally.Then I stop server with
docker-compose stop photoprism.In
docker-compose logs photoprism, nothing is logged on shutdown.In
docker inspect photoprism_photoprism_1, the exit status is 143.According to this code, the exit status should be 1:
photoprism/internal/commands/start.go
Lines 167 to 171 in e1280b2
because the docker entrypoint script traps SIGTERM and sends SIGUSR1 to photoprism:
photoprism/scripts/dist/entrypoint.sh
Line 123 in e1280b2