Make restart-server refuse to run if non-Humbug user on deployment

If you're running this as a user other than "humbug" on a deployed server,
you're going to have a bad time.

Specifically, memcached won't work, and other undefined behaviour may
occur.

So here we add a check and error out if you run this script on an
app_frontend as non-"humbug".

(imported from commit a3d5f0f58ded42393c03f4d21b4650494fae418f)
This commit is contained in:
Luke Faraone 2013-06-19 11:25:42 -04:00
parent 2b320f8d57
commit df1211e6af
1 changed files with 6 additions and 0 deletions

View File

@ -14,6 +14,12 @@ logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..')) deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
os.chdir(deploy_path) os.chdir(deploy_path)
if os.path.exists("/etc/humbug-server"):
with open("/etc/humbug-machinetype") as mtf:
if os.getlogin() != "humbug":
logging.error("Must be run as user 'humbug'.")
sys.exit(1)
# Send a statsd event on restarting the server # Send a statsd event on restarting the server
subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))]) subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))])