From df1211e6af5fe30f1a436a084d40090e6c5374b3 Mon Sep 17 00:00:00 2001 From: Luke Faraone Date: Wed, 19 Jun 2013 11:25:42 -0400 Subject: [PATCH] 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) --- tools/restart-server | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/restart-server b/tools/restart-server index c8bd0c89fe..88fa9c401e 100755 --- a/tools/restart-server +++ b/tools/restart-server @@ -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__), '..')) 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 subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))])