Sha256: 9e7d8018408c61843fdd2cc0158e93e7b6dcdabffb8199fd4d2d3d2289a0a76e

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

#!/bin/bash --login

app_path="/home/deploy/app/current"
shared_path="/home/deploy/app/shared"

# Log output of this script to file in /tmp
set -x
exec > /tmp/app_update.log 2>&1

RAILS_ENV=$1
ROLE=$2
BUCKET_NAME=$3

if [ -z $RAILS_ENV ]; then
    echo Environment must be informed
    exit 1
fi

if [ -z ROLE ]; then
    echo Role must be informed
    exit 1
fi

if [ $RAILS_ENV = 'production' ]; then
    FILENAME=source.zip
else
    FILENAME=source-hml.zip
fi

if [ -z $ROLE ]; then
    ROLE="web"
fi


echo Updating Role: $ROLE

echo Deleting old files
rm -rf ./*
rm -rf ./.*
echo done.

echo Downloading source code from S3 : $FILENAME
wget http://taxweb-deploy.s3.amazonaws.com/$BUCKET_NAME/$FILENAME -O $FILENAME >/dev/null 2>&1
echo done.

echo Extracting source code

unzip -o -q $FILENAME
echo done.

echo Installing new gems...
cd /tmp
cd $app_path
bundle config git.allow_insecure true && bundle install --without development test
echo done.

export RAILS_ENV=$RAILS_ENV

if [ $ROLE = "web" ]; then
    echo Compiling Assets...
    rake assets:precompile
    echo Restarting Passenger
    sudo touch tmp/restart.txt
fi

<%- @roles.each do |role| %>
if [ $ROLE = "<%= role %>" ]; then
    cd $app_path && mkdir -p log
    echo Restarting Workers <%= role %>...
    chmod 755 $app_path/aws/scripts/run_delayed_job.sh
    $app_path/aws/scripts/run_delayed_job.sh stop $ROLE
    pkill -9 -f delayed
    $app_path/aws/scripts/run_delayed_job.sh start $ROLE
fi
<% end %>

echo done Role: $ROLE

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws_stack_builder-0.1.0 lib/generators/aws_stack_builder/templates/aws/scripts/app_update.sh.template