droplet settings: Fix hostname-related settings.

We recently changed our droplet setup such that their
host names no longer include zulipdev.org.  This caused
a few things to break.

The particular symptom that this commit fixes is that
we were trying to server static assets from
showell:9991 instead of showell.zulipdev.org:9991,
which meant that you couldn't use the app locally.
(The server would start, but the site's pretty unusable
without static assets.)

Now we rely 100% on `dev_settings.py` to set
`EXTERNAL_HOST` for any droplet users who don't set
that var in their own environment.  That allows us to
remove some essentially duplicate code in `run-dev.py`.

We also set `IS_DEV_DROPLET` explicitly, so that other
code doesn't have to make inferences or duplicate
logic to detemine whether we're a droplet or not.

And then in `settings.py` we use `IS_DEV_DROPLET` to
know that we can use a prod-like method of calculating
`STATIC_URL`, instead of hard coding `localhost`.

We may want to iterate on this further--this was
sort of a quick fix to get droplets functional again.
It's possible we can re-configure droplets to have
folks get reasonable `EXTERNAL_HOST` settings in their
bash profiles, or something like that, although that
may have its own tradeoffs.
This commit is contained in:
Steve Howell
2020-04-24 18:47:22 +00:00
committed by Tim Abbott
parent 62e9a29064
commit e47e1cd648
3 changed files with 13 additions and 7 deletions

View File

@@ -4,7 +4,6 @@ import argparse
import os
import pwd
import signal
import socket
import subprocess
import sys
import traceback
@@ -79,8 +78,6 @@ if options.interface is None:
# host. The same argument applies to the remote development
# servers using username "zulipdev".
options.interface = None
if user_name == "zulipdev":
os.environ.setdefault("EXTERNAL_HOST", socket.gethostname() + ":9991")
else:
# Otherwise, only listen to requests on localhost for security.
options.interface = "127.0.0.1"