Skip to content
Snippets Groups Projects
Commit 48d62fe6 authored by roadscape's avatar roadscape
Browse files

support for external postgres

parent 03998f3f
No related branches found
No related tags found
No related merge requests found
...@@ -50,8 +50,10 @@ WORKDIR /app ...@@ -50,8 +50,10 @@ WORKDIR /app
ADD scripts/entrypoint.sh /usr/local/bin/entrypoint.sh ADD scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
ADD scripts/hivesync.sh /usr/local/bin/hivesync.sh ADD scripts/hivesync.sh /usr/local/bin/hivesync.sh
ADD scripts/hivesynccontinue.sh /usr/local/bin/hivesynccontinue.sh
RUN chmod +x /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/hivesync.sh RUN chmod +x /usr/local/bin/hivesync.sh
RUN chmod +x /usr/local/bin/hivesynccontinue.sh
RUN \ RUN \
pip3 install . && \ pip3 install . && \
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
# a non-micro-fork was encountered. Hive has a startup routine which attempts # a non-micro-fork was encountered. Hive has a startup routine which attempts
# to recover automatically, so database should be kept intact between restarts. # to recover automatically, so database should be kept intact between restarts.
# eb need to set: RUN_IN_EB, S3_BUCKET, SYNC_TO_S3 (boolean) if a syncer # eb with self-contained postgres need to set: RUN_IN_EB, S3_BUCKET, and SYNC_TO_S3 (boolean) if a syncer
# eb with external postgres do not require RUN_IN_EB, S3_BUCKET, or SYNC_TO_S3
# with external postgres need to set: SYNC_SERVICE if a syncer
# hive expects: DATABASE_URL, LOG_LEVEL, STEEMD_URL, JUSSI_URL # hive expects: DATABASE_URL, LOG_LEVEL, STEEMD_URL, JUSSI_URL
# default DATABASE_URL should be postgresql://postgres:postgres@localhost:5432/postgres # default DATABASE_URL should be postgresql://postgres:postgres@localhost:5432/postgres
...@@ -65,24 +67,39 @@ if [[ "$RUN_IN_EB" ]]; then ...@@ -65,24 +67,39 @@ if [[ "$RUN_IN_EB" ]]; then
service postgresql restart service postgresql restart
fi fi
fi cd $APP_ROOT
# startup hive
cd $APP_ROOT echo hivemind: starting sync
exec "${POPULATE_CMD}" sync 2>&1&
# startup hive
echo hivemind: starting sync
exec "${POPULATE_CMD}" sync 2>&1&
echo hivemind: starting server echo hivemind: starting server
if [[ ! "$SYNC_TO_S3" ]]; then if [[ ! "$SYNC_TO_S3" ]]; then
exec "${POPULATE_CMD}" server exec "${POPULATE_CMD}" server
else
exec "${POPULATE_CMD}" server --log-level=warning 2>&1&
mkdir -p /etc/service/hivesync
cp /usr/local/bin/hivesync.sh /etc/service/hivesync/run
chmod +x /etc/service/hivesync/run
echo hivemind: starting hivesync service
runsv /etc/service/hivesync
fi
else else
exec "${POPULATE_CMD}" server --log-level=warning 2>&1& # start hive with an external postgres
cd $APP_ROOT
if [[ "$SYNC_SERVICE" ]]; then
echo hivemind: starting sync
exec "${POPULATE_CMD}" sync 2>&1&
echo hivemind: starting server
exec "${POPULATE_CMD}" server 2>&1&
# make sure hive sync and server continually run
mkdir -p /etc/service/hivesync mkdir -p /etc/service/hivesync
cp /usr/local/bin/hivesync.sh /etc/service/hivesync/run cp /usr/local/bin/hivesynccontinue.sh /etc/service/hivesync/run
chmod +x /etc/service/hivesync/run chmod +x /etc/service/hivesync/run
echo hivemind: starting hivesync service
runsv /etc/service/hivesync runsv /etc/service/hivesync
else
echo hivemind: starting server
exec "${POPULATE_CMD}" server
fi
fi fi
echo hivemind: application has stopped, see log for errors echo hivemind: application has stopped, see log for errors
#!/bin/bash
POPULATE_CMD="$(which hive)"
HIVESYNC_PID=`pgrep -f 'hive sync'`
if [[ ! $? -eq 0 ]]; then
echo NOTIFYALERT! hivemindsync quit unexpectedly, restarting hive sync...
cd $APP_ROOT
exec "${POPULATE_CMD}" sync 2>&1&
fi
sleep 30
HIVESERVER_PID=`pgrep -f 'hive server'`
if [[ ! $? -eq 0 ]]; then
echo NOTIFYALERT! hivemindserver quit unexpectedly, restarting hive server...
cd $APP_ROOT
exec "${POPULATE_CMD}" server 2>&1&
fi
# prevent flapping
sleep 120
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment