2013-01-30 23:11:34 +01:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# Update static files in production.
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"/..
|
|
|
|
|
|
|
|
# Redirect output to a log file (most recent run only)
|
|
|
|
exec >update-prod-static.log
|
|
|
|
|
2013-02-25 23:53:16 +01:00
|
|
|
# Collect both original and minified files.
|
|
|
|
#
|
|
|
|
# We don't delete the old files, because doing so makes the
|
|
|
|
# running app with PipelineCachedStorage unhappy. So if you
|
|
|
|
# remove a static file, you need to manually remove it from
|
|
|
|
# prod-static/collected on the app servers.
|
2013-01-30 23:11:34 +01:00
|
|
|
./manage.py collectstatic --noinput
|
|
|
|
|
|
|
|
# Copy the files we want to expose
|
|
|
|
rm -rf prod-static/serve-new
|
2013-02-25 02:59:59 +01:00
|
|
|
mkdir -p prod-static/serve-new
|
2013-02-05 17:49:37 +01:00
|
|
|
cp -r prod-static/collected/{favicon.ico,robots.txt,html,images,third,min} prod-static/serve-new/
|
2013-01-30 23:11:34 +01:00
|
|
|
|
|
|
|
# Sync the new directory to the one nginx actually serves.
|
|
|
|
# Hopefully this doesn't race too badly for clients loading
|
|
|
|
# right as a deploy happens.
|
|
|
|
mkdir -p prod-static/serve
|
|
|
|
rsync -ar --delete prod-static/serve-new/* prod-static/serve/
|
|
|
|
|
|
|
|
# Clean up
|
2013-02-24 19:28:43 +01:00
|
|
|
rm -rf prod-static/serve-new
|
|
|
|
|
|
|
|
# Leave the 'collected' directory around or PipelineCachedStorage
|
|
|
|
# will fail.
|