Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup-postgres.sh: load a .sql.gz file conveniently #32

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ixc_django_docker/bin/npm-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ if [[ ! -s package.json ]]; then
EOF
fi

UNAME="$(uname)"
md5file=package.json.md5.$(uname)

touch "package.json.md5.$UNAME"

if [[ ! -s "package.json.md5.$UNAME" ]] || ! md5sum --status -c "package.json.md5.$UNAME" > /dev/null 2>&1; then
[[ -s "$md5file" ]] && md5sum --status -c "$md5file" > /dev/null 2>&1 \
|| {
echo "Node modules in '$DIR' directory are out of date, 'package.json' has been updated."
if [[ -d node_modules && -z ${NPM_INSTALL_SH_SKIP_CLEAN+1} ]]; then
rm -rf node_modules/*
Expand All @@ -38,5 +37,5 @@ if [[ ! -s "package.json.md5.$UNAME" ]] || ! md5sum --status -c "package.json.md
npm install --unsafe-perm
fi
rm -f package.json.md5.* # 'node_modules' is shared, if we rebuild for one platform, other platforms become invalid
md5sum package.json > "package.json.md5.$UNAME"
fi
md5sum package.json > "$md5file"
}
5 changes: 5 additions & 0 deletions ixc_django_docker/bin/setup-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ if [[ "$SRC_PGDATABASE" == *.sql ]]; then
echo "Restore to database '$PGDATABASE' from file '$SRC_PGDATABASE'."
pv "$SRC_PGDATABASE" | psql -d "$PGDATABASE" > /dev/null
fi
elif [[ "$SRC_PGDATABASE" == *.sql.gz ]]; then
if [[ -f "$SRC_PGDATABASE" ]]; then
echo "Restore to database '$PGDATABASE' from file '$SRC_PGDATABASE'."
pv "$SRC_PGDATABASE" | gunzip | psql -d "$PGDATABASE" > /dev/null
fi
elif [[ -n "$SRC_PGDATABASE" ]]; then
# Get source database credentials.
SRC_PGHOST="${SRC_PGHOST:-${PGHOST}}"
Expand Down
4 changes: 2 additions & 2 deletions ixc_django_docker/celery/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import

from celery.task import task
from .celery import app
from django.core import management
import decorator
import redis_lock
Expand Down Expand Up @@ -49,7 +49,7 @@ def skip_concurrent(f, lock_kwargs=None, *args, **kwargs):
return 'Skipped. Unable to acquire lock: %s' % name


@task
@app.task
@skip_concurrent
def call_command(*args, **kwargs):
return management.call_command(*args, **kwargs)