Preparing a sample application

Throughout the rest of this basics tutorial, we will demonstrate Passenger's basic features through a sample Meteor application. In this step we will show you how to create this sample application.

Create the app

Let us create an example Meteor app directory structure in your home directory. We use the builtin Meteor leaderboard example app. If you have already done this as part of the quickstart, feel free to skip to "Create an app package".

$ cd ~
$ meteor create --example leaderboard
$ cd leaderboard

Create an app package

In the previous step, you only created a Meteor app in development mode. In this tutorial, we also need a packaged version of your Meteor sample app. A packaged Meteor app contains the Meteor runtime and various other necessary things for running a Meteor app in production. Some Passenger features are only compatible with packaged Meteor apps.

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

Inside the leaderboard directory, use the meteor bundlemeteor build command to create a package tarball.

$ meteor build --server-only ../leaderboard-package
$ meteor bundle package.tar.gz

Why create a package?

Wondering why we instruct you to create a package, instead of just using the Meteor app in unpackaged form? Learn more at About Meteor support.

"meteor bundle" deprecated?

Meteor will probably tell you that meteor bundle is deprecated in favor of meteor build. Please ignore that message, because for the purpose of running a Meteor web application on Passenger, only meteor bundle does what we want.

meteor bundle creates a packaged web application, in the form of a Node.js web app with the Meteor runtime included. meteor build is a more comprehensive tool that not only does what meteor bundle does, but also builds iOS and Android app packages. However, Passenger is a web application server, so iOS and Android packages are not relevant to us, which is why we recommend using meteor bundle instead of meteor build.

The packaged app has now been placed in package.tar.gz. But Passenger expects a directory, so let us extract it in ../leaderboard-package:

$ mkdir ../leaderboard-package
$ cd ../leaderboard-package
$ tar xzf ../leaderboard/package.tar.gz
$ cd ../leaderboard-package
$ tar xzf *.tar.gz

The packaged app directory doesn't contain any dependencies, so we need to install them. Run:

$ cd bundle/programs/server
$ npm install

Finally, return to the original leaderboard app directory:

$ cd ~/leaderboard-package/bundle

Meteor package and MongoDB

During development, the Meteor runtime takes care of starting MongoDB for you. MongoDB is the database engine that Meteor uses.

But a packaged Meteor app does not start MongoDB for you. Instead, a packaged Meteor app expects that MongoDB is already running somewhere, and that you tell the app where that MongoDB instance is. In the Process management section we will show you how to run MongoDB separately and how to tell your app where MongoDB is.

Next step

Next, we will introduce you to the passenger command, which starts your app in Passenger.

Continue »