Created
December 30, 2019 15:14
-
-
Save joaquinacuna/7a2b0fe5108769279d7e9b1ca822b677 to your computer and use it in GitHub Desktop.
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
def deploy(ctx): | |
pull_result = ctx.run("git pull") | |
if is_task_file_changed(pull_result): | |
sys.exit("Pyinvoke task file(s) is changed. Please re-run this task.") | |
ctx.run("pip install -r requirements.txt") | |
ctx.run("python manage.py makemigrations") | |
ctx.run("python manage.py migrate") | |
ctx.run("python manage.py collectstatic --noinput") | |
# Reload application. | |
ctx.run("touch ../reload") | |
# Restart receiving server and batch server. | |
ctx.run("sudo restart sh8recv", pty=True) | |
ctx.run("sudo restart sh8batch", pty=True) | |
# Give some time for reloading application. | |
time.sleep(1) | |
# Test if the site works well. | |
with urlopen("https://sh8.email") as response: | |
if not response.getcode() == 200: | |
sys.exit("CRITICAL: The site respond CODE " + response.getcode()) | |
# Success! | |
print("Deploy succeeded.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment