2021-04-15 22:35:17 -04:00
|
|
|
#!/usr/bin/env sh
|
2019-12-03 13:36:50 -05:00
|
|
|
|
2022-02-06 13:27:01 -05:00
|
|
|
# Create S3 dirs
|
|
|
|
mkdir -p /srv/philomena/priv/s3/philomena
|
2022-02-08 21:32:12 -05:00
|
|
|
ln -sf /srv/philomena/priv/static/system/images/thumbs /srv/philomena/priv/s3/philomena/images
|
|
|
|
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/adverts
|
|
|
|
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/avatars
|
|
|
|
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/badges
|
|
|
|
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/tags
|
2022-02-06 13:27:01 -05:00
|
|
|
|
2021-09-12 10:27:02 -04:00
|
|
|
# For compatibility with musl libc
|
|
|
|
export CARGO_FEATURE_DISABLE_INITIAL_EXEC_TLS=1
|
2021-09-27 19:12:46 -04:00
|
|
|
export CARGO_HOME=/srv/philomena/.cargo
|
2021-09-12 10:27:02 -04:00
|
|
|
|
2020-10-26 17:01:29 -04:00
|
|
|
background() {
|
|
|
|
while :; do
|
|
|
|
mix run -e 'Philomena.Release.update_channels()'
|
2020-11-26 14:21:24 -06:00
|
|
|
mix run -e 'Philomena.Release.verify_artist_links()'
|
2020-10-26 17:01:29 -04:00
|
|
|
mix run -e 'Philomena.Release.update_stats()'
|
2021-11-08 11:41:13 +01:00
|
|
|
mix run -e 'Philomena.Release.clean_moderation_logs()'
|
2021-12-26 19:16:21 -05:00
|
|
|
mix run -e 'Philomena.Release.generate_autocomplete()'
|
2020-10-26 17:01:29 -04:00
|
|
|
|
|
|
|
sleep 300
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-12-03 13:36:50 -05:00
|
|
|
# Always install assets
|
2020-02-10 22:27:09 -05:00
|
|
|
(
|
|
|
|
cd /srv/philomena/assets
|
2021-10-08 21:31:54 -04:00
|
|
|
npm install
|
2020-02-10 22:27:09 -05:00
|
|
|
)
|
2019-12-03 13:36:50 -05:00
|
|
|
|
|
|
|
# Always install mix dependencies
|
|
|
|
(cd /srv/philomena && mix deps.get)
|
|
|
|
|
|
|
|
# Sleep to allow Elasticsearch to finish initializing
|
|
|
|
# if it's not done doing whatever it does yet
|
|
|
|
echo -n "Waiting for Elasticsearch"
|
|
|
|
|
2019-12-03 17:56:26 -05:00
|
|
|
until wget -qO - elasticsearch:9200; do
|
2019-12-03 13:36:50 -05:00
|
|
|
echo -n "."
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Try to create the database if it doesn't exist yet
|
2021-04-15 22:35:17 -04:00
|
|
|
createdb -h postgres -U postgres philomena_dev && mix ecto.setup_dev && mix reindex_all
|
2020-04-29 22:28:56 -04:00
|
|
|
|
2021-09-27 18:59:45 -04:00
|
|
|
# Explicitly compile deps to avoid racing
|
|
|
|
mix compile
|
|
|
|
|
2020-10-26 17:01:29 -04:00
|
|
|
# Run background jobs
|
|
|
|
background &
|
|
|
|
|
2019-12-03 13:36:50 -05:00
|
|
|
# Run the application
|
2021-04-16 09:21:34 -04:00
|
|
|
START_WORKER=true exec mix phx.server
|