Skip to content

Commit c4dbc02

Browse files
Fix startup scripts when restarting container (#476)
`20_start-postgresql.sh` and `40_prepare_aiida.sh` scripts were broken, as they would fail when a container was restarted. - Delete old ${PSQL_LOGFILE}.1.gz file before trying to create a new one - Remove stale verdi daemon pid files, which would cause the `verdi migrate` commands to fail. This is faster than `verdi daemon stop`. We suppose that the daemon is not running when we start/restart the container. --------- Co-authored-by: Daniel Hollas <[email protected]>
1 parent c58b00f commit c4dbc02

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

stack/base-with-services/before-notebook.d/20_start-postgresql.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ else
2222
chmod -R g-rwxs "${PGDATA}"
2323

2424
if [[ -f ${PGDATA}/logfile ]]; then
25-
mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1"
25+
rm -f "${PSQL_LOGFILE}.1.gz"
26+
mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1"
2627
fi
2728
# Cleaning up the mess if PostgreSQL was not shutdown properly.
2829
rm -vf "${PGDATA}/postmaster.pid"

stack/base/before-notebook.d/40_prepare-aiida.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter
7474
else
7575

7676
# Migration will run for the default profile.
77+
pgrep -af 'verdi.* daemon' && echo "ERROR: AiiDA daemon is already running!" && exit 1
78+
## clean up stale PID-files -> .aiida/daemon/circus-{profile-name}.pid
79+
rm -f /home/${NB_USER}/.aiida/daemon/circus-*.pid
7780
verdi storage migrate --force
7881

7982
fi

0 commit comments

Comments
 (0)