Skip to content

Instantly share code, notes, and snippets.

@joaquinacuna
Created December 30, 2019 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaquinacuna/7a2b0fe5108769279d7e9b1ca822b677 to your computer and use it in GitHub Desktop.
Save joaquinacuna/7a2b0fe5108769279d7e9b1ca822b677 to your computer and use it in GitHub Desktop.
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