Skip to content

Commit

Permalink
Fix startup scripts when restarting container (#476)
Browse files Browse the repository at this point in the history
`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 <danekhollas@gmail.com>
  • Loading branch information
mikibonacci and danielhollas authored Jul 4, 2024
1 parent c58b00f commit c4dbc02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ else
chmod -R g-rwxs "${PGDATA}"

if [[ -f ${PGDATA}/logfile ]]; then
mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1"
rm -f "${PSQL_LOGFILE}.1.gz"
mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1"
fi
# Cleaning up the mess if PostgreSQL was not shutdown properly.
rm -vf "${PGDATA}/postmaster.pid"
Expand Down
3 changes: 3 additions & 0 deletions stack/base/before-notebook.d/40_prepare-aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter
else

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

fi
Expand Down

0 comments on commit c4dbc02

Please sign in to comment.