Deploying application updates
with Passenger in Nginx mode

In the previous step, you deployed an application to your production server for the first time. But what do you do when you have updated your app, and need to deploy updates? You will learn that on this page.

Table of contents

  • Loading...

1 Transferring latest code

1.1 Build and upload new package

In order to provide you appropriate instructions, please choose your Meteor version:

Inside your application's code directory, on your local computer, use the meteor bundlemeteor build command to create a Meteor package tarball of the latest application code.

local-computer$ meteor bundle package.tar.gz
local-computer$ meteor build --server-only ../new_package && mv ../new_package/*.tar.gz ./package.tar.gz

Copy the package to your production server, for example using scp:

local-computer$ scp -i your_ec2_key.pem package.tar.gz myappuser@yourserver.com:

Replace myappuser with name of the application's OS user account.

1.2 Login to the server as the application's user

Login to your server with SSH:

local-computer$ ssh -i your_ec2_key.pem myappuser@yourserver.com

Replace myappuser with name of the application's OS user account.

Starting from this point, unless stated otherwise, all commands that we instruct you to run should be run on the server, not on your local computer!

1.3 Extract package

Extract the package to a temporary location, for example /var/www/yourapp/tmp.

$ mkdir -p /var/www/myapp/tmp
$ cd /var/www/myapp/tmp
$ tar xzf ~/package.tar.gz

Replace myapp and myappuser with your app's name and your app user account's name.

The extracted package is now located in /var/www/myapp/tmp/bundle.

2 Prepare application

2.1 Install app dependencies

Your application's npm dependencies may have changed, so we should install any updated npm dependencies while removing any now-extraneous dependencies. Run:

$ cd /var/www/myapp/tmp/bundle/programs/server
$ npm install --production
$ npm prune --production

3 Activate application updates

Passenger may still be serving an old instance of your application. Now that all application updates have been prepared, it is time to activate the newly uploaded application package.

Rename the old application directory to something different, and move the new application directory to where the old application directory was:

$ mv /var/www/myapp/bundle /var/www/myapp/bundle.old
$ mv /var/www/myapp/tmp/bundle /var/www/myapp/bundle

Tell Passenger to restart the application so that the updates take effect.

$ passenger-config restart-app /var/www/myapp/bundle

Wait a few seconds (for Passenger to do its job), then remove the old application directory:

$ rm -rf /var/www/myapp/bundle.old

Next step

Continue: Conclusion »