Browse Source

new: [vps] add ``vps cyclos unlock`` command to release lock on database

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
rc1
Valentin Lab 3 years ago
parent
commit
0e7f5621b8
  1. 41
      bin/vps

41
bin/vps

@ -706,6 +706,15 @@ cyclos:set_root_url() {
export -f cyclos:set_root_url export -f cyclos:set_root_url
cyclos:unlock() {
local project_name="$1" dbname="$2" url="$3"
echo "delete from database_lock;" |
compose:psql "${project_name}" "${dbname}"
}
export -f cyclos:unlock
compose:project_name() { compose:project_name() {
if [ -z "$PROJECT_NAME" ]; then if [ -z "$PROJECT_NAME" ]; then
PROJECT_NAME=$(compose --get-project-name) || { PROJECT_NAME=$(compose --get-project-name) || {
@ -1316,11 +1325,8 @@ EOF
postgres:restore "$project_name" "$GZ_DUMP_LOCATION" "${cyclos_service}@${cyclos_database}" || exit 1 postgres:restore "$project_name" "$GZ_DUMP_LOCATION" "${cyclos_service}@${cyclos_database}" || exit 1
## ensure that the database is not locked ## ensure that the database is not locked
## XXXvlab: 70 is uid of user postgres, this avoids the docker bug
## but introduce hardwritten value
Wrap -d "check and remove database lock if any" <<EOF || exit 1
echo "delete from database_lock;" | compose:psql "${project_name}" "${cyclos_database}"
EOF
Wrap -d "check and remove database lock if any" -- \
cyclos:unlock "${project_name}" "${cyclos_database}" || exit 1
Wrap -d "set root url to '$url'" -- \ Wrap -d "set root url to '$url'" -- \
cyclos:set_root_url "${project_name}" "${cyclos_database}" "${url}" || exit 1 cyclos:set_root_url "${project_name}" "${cyclos_database}" "${url}" || exit 1
@ -1357,4 +1363,29 @@ cmdline.spec:cyclos:cmd:set-root-url:run() {
} }
cmdline.spec.gnu unlock
cmdline.spec:cyclos:cmd:unlock:run() {
: :optval: --database,-d "Target database ('cyclos' if not specified)"
: :optval: --service,-s "The cyclos service name (defaults to 'cyclos')"
local URL
cyclos_database=${opt_database:-cyclos}
cyclos_service="${opt_service:-cyclos}"
project_name=$(compose:project_name) || exit 1
container_id=$(compose:service:container_one "${project_name}" "${cyclos_service}") || exit 1
Wrap -d "stop ${DARKYELLOW}${cyclos_service}${NORMAL}'s container" -- \
docker stop "$container_id" || exit 1
Wrap -d "check and remove database lock if any" -- \
cyclos:unlock "${project_name}" "${cyclos_database}" || exit 1
Wrap -d "start ${DARKYELLOW}${cyclos_service}${NORMAL}'s container" -- \
docker start "${container_id}" || exit 1
}
cmdline::parse "$@" cmdline::parse "$@"
Loading…
Cancel
Save