diff --git a/conf/systemd-beat.service b/conf/systemd-beat.service index 42fe1f0..5cbbfb7 100644 --- a/conf/systemd-beat.service +++ b/conf/systemd-beat.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.scoket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source +WorkingDirectory=__INSTALL_DIR__/sources/ ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django ExecReload=/bin/kill -s HUP $MAINPID diff --git a/conf/systemd-celery.service b/conf/systemd-celery.service index e050e9d..3b3074d 100644 --- a/conf/systemd-celery.service +++ b/conf/systemd-celery.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.socket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source +WorkingDirectory=__INSTALL_DIR__/sources/ ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ worker -l info -Ofair ExecReload=/bin/kill -s HUP $MAINPID diff --git a/conf/systemd.service b/conf/systemd.service index bc603fc..7eb4da5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,9 +7,9 @@ Requires=__APP__.socket Type=notify User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source/ +WorkingDirectory=__INSTALL_DIR__/sources/ -ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/source/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/sources/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed diff --git a/scripts/_common.sh b/scripts/_common.sh index 7b28c6a..3b9cc22 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -27,14 +27,14 @@ function set_up_virtualenv { ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements-setup.txt" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" } function initialize_db { perform_db_migrations - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 } function upgrade_db { @@ -42,8 +42,8 @@ function upgrade_db { } function perform_db_migrations { - yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" makemigrations --merge - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" migrate + yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" makemigrations --merge + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" migrate } #================================================= diff --git a/scripts/install b/scripts/install index 3b3c3b0..f862915 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key" ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/source" +ynh_setup_source --dest_dir="$install_dir/sources" #================================================= # APP INITIAL CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index dd25e53..205a5bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,13 +45,18 @@ if [[ -n "${random_key:-}" ]]; then ynh_app_setting_set --app="$app" --key=secret_key --value="$random_key" fi +if [ -f "$install_dir/requirements.txt" ]; then + # Move to $install_dir/sources + find "$install_dir" -maxdepth 1 -mindepth 1 -not -name envs -exec rm -rf {} + +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 +ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 #================================================= # APP INITIAL CONFIGURATION