Skip to content

Commit

Permalink
create-database: Skip stop-server and flush-memcached on standalone Pg.
Browse files Browse the repository at this point in the history
If running on a stand-alone PostgreSQL server, then supervisor does
exist -- but `stop-server` is useless, and in fact cannot run because
the Zulip directory may not be readable by the `zulip` user.

Detect if this is an application front-end server by looking for
`/home/zulip/deployments`, and use the stop-server and flush-memcached
from there if it exists.  The `create-db.sql` and
`terminate-psql-sessions` files are still read from the local
directory, but those already have precautions from being from a
non-world-readable directory, and are more obviously important to keep
in sync with the `create-database` script.
  • Loading branch information
alexmv authored and timabbott committed Apr 4, 2024
1 parent c56dd5e commit acc94a5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/setup/create-database
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ if [ "$(su "$POSTGRES_USER" -c "cd / && psql -v ON_ERROR_STOP=1 -Atc \"SELECT 1
fi

# Shut down all services to ensure a quiescent state.
if [ -e "/var/run/supervisor.sock" ]; then
su zulip -c "$(dirname "$0")/../stop-server"
if [ -e "/home/zulip/deployments" ]; then
su zulip -c "/home/zulip/deployments/current/scripts/stop-server"
fi

# Drop any open connections to any old database.
Expand All @@ -54,6 +54,8 @@ EOF
fi

# Clear memcached to avoid contamination from previous database state
"$(dirname "$0")/flush-memcached"
if [ -e "/home/zulip/deployments" ]; then
/home/zulip/deployments/current/scripts/setup/flush-memcached
fi

echo "Database created"

0 comments on commit acc94a5

Please sign in to comment.