mirror of https://github.com/zulip/zulip.git
Split restart-server code out of update-deployment.
(imported from commit 3ae913b950be0a0c94fbaf0173012ea315f36d62)
This commit is contained in:
parent
54cfea9252
commit
9cc3e29de5
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import pylibmc
|
||||
import traceback
|
||||
|
||||
# Color codes
|
||||
OKBLUE = '\033[94m'
|
||||
OKGREEN = '\033[92m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
|
||||
os.chdir("/home/humbug/humbug")
|
||||
|
||||
#subprocess.check_call(["python", "manage.py", "syncdb"], stdout=open('/dev/null', 'w'))
|
||||
|
||||
try:
|
||||
if not pylibmc.Client(['127.0.0.1']).flush_all():
|
||||
print "%sflush_all returned False%s" % (WARNING, ENDC)
|
||||
# There doesn't seem to be a method to close a pylibmc Client object.
|
||||
except:
|
||||
print "%sCould not flush cache:%s" % (WARNING, ENDC)
|
||||
traceback.print_exc()
|
||||
|
||||
# Delete all .pyc files to avoid old module files hanging around
|
||||
subprocess.check_call(["find", ".", "-name", "*.pyc", "-delete"], stdout=open('/dev/null', 'w'))
|
||||
|
||||
# Restart the FastCGI process, which is running in a shell loop in screen.
|
||||
# TODO: real daemonization
|
||||
for cmd in ('runfcgi', 'runtornado'):
|
||||
try:
|
||||
subprocess.check_call(["pkill", "-f", "python manage.py " + cmd])
|
||||
except subprocess.CalledProcessError:
|
||||
print "%sCould not kill %s; is it running?%s" % (WARNING, cmd, ENDC)
|
||||
|
||||
print OKGREEN + "Application restarted successfully!" + ENDC
|
|
@ -33,30 +33,10 @@ if len(sys.argv) > 1:
|
|||
newrev = sys.argv[2]
|
||||
refname = sys.argv[3]
|
||||
|
||||
try:
|
||||
if not pylibmc.Client(['127.0.0.1']).flush_all():
|
||||
print "%sflush_all returned False%s" % (WARNING, ENDC)
|
||||
# There doesn't seem to be a method to close a pylibmc Client object.
|
||||
except:
|
||||
print "%sCould not flush cache:%s" % (WARNING, ENDC)
|
||||
traceback.print_exc()
|
||||
|
||||
subprocess.check_call(["git", "fetch"], stdout=open('/dev/null', 'w'))
|
||||
subprocess.check_call(["git", "reset", "--hard", refname], stdout=open('/dev/null', 'w'))
|
||||
#subprocess.check_call(["python", "manage.py", "syncdb"], stdout=open('/dev/null', 'w'))
|
||||
|
||||
# Delete all .pyc files to avoid old module files hanging around
|
||||
subprocess.check_call(["find", ".", "-name", "*.pyc", "-delete"], stdout=open('/dev/null', 'w'))
|
||||
|
||||
# Restart the FastCGI process, which is running in a shell loop in screen.
|
||||
# TODO: real daemonization
|
||||
for cmd in ('runfcgi', 'runtornado'):
|
||||
try:
|
||||
subprocess.check_call(["pkill", "-f", "python manage.py " + cmd])
|
||||
except subprocess.CalledProcessError:
|
||||
print "%sCould not kill %s; is it running?%s" % (WARNING, cmd, ENDC)
|
||||
|
||||
print OKGREEN + "Updated deployed version of humbug application!" + ENDC
|
||||
subprocess.check_call(["./tools/restart-server"])
|
||||
|
||||
if newrev == '0000000000000000000000000000000000000000':
|
||||
# 0000000000000000000000000000000000000000 means we're deleting the ref
|
||||
|
|
Loading…
Reference in New Issue