Resources for Developers

Meteor on Scalingo

Meteor is a complete open source platform for building web and mobile apps in pure JavaScript. It focuses problematics around real time web to emphasize the most fluent experience possible.

Getting started tutorial

Deploy your first Meteor application: follow the guide

Deploy an existing application like Telescope: follow the guide

Meteor app detection

The directory .meteor should be present at the root of your project

Meteor dependencies installation

  • Using Meteor embedded dependency management (with meteor add and meteor update)
  • Using npm package manager (with meteor npm <command>)

Node and npm versions

If defined, Node.js version and npm version are read from the engines section of the package.json file. If no version is defined, we’ll install the latest stable version compatible with your Meteor application.

{
  "name": "myapp",
  "engines": {
    "node": "4.8.x",
    "npm": "3.x"
  }
}
Meteor Node.js npm yarn
1.6 8.8.x 5.x 1.5
1.5 4.8.x 4.6.x n/a
1.4 4.8.x 4.6.x n/a
<= 1.3 0.10.x 3.x n/a

Meteor app startup

A script named .start-meteor-app is automatically generated after the build of your application. Its role is to start correctly your application.

Generated .start-meteor-app:

cd .app-build/bundle/programs/server
exec node boot.js program.json

The buildpack also generates a .release file

default_process_types:
  web: ./.start-meteor-app

If no Procfile exists, the web type of the .release will be executed by default. If your wish to write your own Procfile don’t forget to keep this line for your web process, otherwise your application may not boot.

Configuration

Meteor settings

If you have a settings.json or a config/settings.json file that you usually run with meteor --settings settings.json, you have nothing to do. It will be handled by our deployment system, but this method is deprecated.

Storing configuration data like credentials in a file present in your Git repository is not recommended. We advise you to use the environment variable METEOR_SETTINGS, the variable is automatically read by Meteor and it stays out of your code repository. You have to set the content of this environment variable (with our CLI or through your web dashboard) to match the content of your settings.json file. Furthermore, using this method allows you to manage easily multiple environment of the same app.

If you’re using a settings.json file, here is the method to migrate to an environment-based setup:

$ echo 'settings.json' >> .gitignore
$ git rm --cached settings.json
$ git add .gitignore
$ git commit -m "Add settings file to gitignore to avoid having credentials in code"
$ scalingo env-set METEOR_SETTINGS="$(cat settings.json)"
$ git push scalingo master

Built-in mobile integration

If you need to use your application as a backend for your Android or iOS application, don’t worry. It is done by default by the platform. You need to use Meteor ≥ 1.3, if that’s the case, the flag --server-only will be used to build your app. Finally, your mobile apps will be able to communicate with it without any problem.

Debug build

By default, Meteor minify all your assets to stand in one single JavaScript file, if you want to make a ‘debug’ build (assets un-minified), please define the following environment variable:

scalingo env-set METEOR_DEBUG_BUILD=true

How to scale Meteor

As a real time framework, the number of scaling constraints is higher than another more classical framework. Each instance is keeping some stateful information and each instance has to be able to get instantly the most up-to-date data. To achieve that, the two common processes used are the sticky sessions and the oplog feature of MongoDB.

Oplog

Oplog is a MongoDB feature which logs all the operations achieved on a MongoDB cluster. Meteor uses this feature to sync different instances of an application.

It can be enabled from the addon database dashboard. When activated it will automatically add the MONGO_OPLOG_URL in your application. This variable name is the standard name to configure Meteor. As a result, you just have to restart your application.

Link to Dashboard

Sticky Sessions

Session affinity is the process of saving on which instance a given user has been routed, in order to use this route again for a given time. Our load balancers have sticky sessions enabled automatically for Meteor apps. A user will keep using the same route during 1 hour.

You have nothing to do except increasing the amount of containers you are using. To do so, open the dashboard of your application, and in the containers tab increase the amount of needed containers. Click on scale and the amount of instances will be scaled instantly.

Buildpack

The deployment of Meteor application is handled by our Node.js Buildpack which has been modified to manage particularly Meteor application.

  1. It detects Meteor application
  2. Choose the good Node.js version
  3. Install Meteor runtime
  4. Build project
  5. Prepare runtime environment

mode_edit Suggest edits