-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
184 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends "sitewide/flat_ui_template.html" %} | ||
{% load custom_tags %} | ||
{% load static %} | ||
|
||
{% block title %}Reload Python Requirements{% endblock %} | ||
|
||
{% block header_scripts %} | ||
{% endblock %} | ||
|
||
|
||
{% block content %} | ||
<h1>Reload Python Requirements</h1> | ||
|
||
<p> | ||
You have triggered a manual reload of the Python packages required by Fermentrack. Please wait several minutes | ||
for this refresh to complete and for Fermentrack to relaunch before proceeding. | ||
</p> | ||
|
||
<p> | ||
Once complete, you can view the <a href="{% url "get_app_log" "text" "upgrade" "stderr" %}">upgrade log</a> to see | ||
what was installed/updated. | ||
</p> | ||
|
||
|
||
{% endblock %} | ||
|
||
|
||
|
||
{% block scripts %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Defaults | ||
SILENT=0 | ||
CIRCUSCTL="python3 -m circus.circusctl --timeout 10" | ||
|
||
# Colors (for printinfo/error/warn below) | ||
green=$(tput setaf 76) | ||
red=$(tput setaf 1) | ||
tan=$(tput setaf 3) | ||
reset=$(tput sgr0) | ||
|
||
|
||
|
||
printinfo() { | ||
if [ ${SILENT} -eq 0 ] | ||
then | ||
printf "::: ${green}%s${reset}\n" "$@" | ||
fi | ||
} | ||
|
||
|
||
printwarn() { | ||
if [ ${SILENT} -eq 0 ] | ||
then | ||
printf "${tan}*** WARNING: %s${reset}\n" "$@" | ||
fi | ||
} | ||
|
||
|
||
printerror() { | ||
if [ ${SILENT} -eq 0 ] | ||
then | ||
printf "${red}*** ERROR: %s${reset}\n" "$@" | ||
fi | ||
} | ||
|
||
|
||
|
||
exec > >(tee -i log/upgrade.log) | ||
|
||
|
||
printinfo "Re-installing Python packages from requirements.txt" | ||
# First, launch the virtualenv | ||
source ~/venv/bin/activate # Assuming the directory based on a normal install with Fermentrack-tools | ||
|
||
# Given that this script can be called by the webapp proper, give it 2 seconds to finish sending a reply to the | ||
# user if he/she initiated an upgrade through the webapp. | ||
printinfo "Waiting 1 second for Fermentrack to send updates if triggered from the web..." | ||
sleep 1s | ||
|
||
# Next, kill the running Fermentrack instance using circus | ||
printinfo "Stopping circus..." | ||
$CIRCUSCTL stop &>> log/upgrade.log | ||
|
||
# Install everything from requirements.txt | ||
printinfo "Updating requirements via pip3..." | ||
pip3 install -U -r requirements.txt --upgrade &>> log/upgrade.log | ||
|
||
# Migrate to create/adjust anything necessary in the database | ||
printinfo "Running manage.py migrate..." | ||
python3 manage.py migrate &>> log/upgrade.log | ||
|
||
# Migrate to create/adjust anything necessary in the database | ||
printinfo "Running manage.py collectstatic..." | ||
python3 manage.py collectstatic --noinput >> /dev/null | ||
|
||
|
||
# Finally, relaunch the Fermentrack instance using circus | ||
printinfo "Relaunching circus..." | ||
$CIRCUSCTL reloadconfig &>> log/upgrade.log | ||
$CIRCUSCTL start &>> log/upgrade.log | ||
printinfo "Complete!" |