Production Quality Meteor Deployments using Passenger Standalone Server
This tool is a fork of [Meteor Up command line tool by Kadhira] (https://github.com/kadirahq/meteor-up) which uses Phusion Passenger server instead Docker.
Phusion Passenger is more Fast & scalable, Easy setup and Stable & Reliable. Most importantly unlike Docker Phusion Passenger doesnt consume server resources too much.
like meteor-up by kadhira, meteor-passenger also allows you to deploy any Meteor app to your own server and it currently supports Ubuntu too.
Table of Contents
- Features
- Installation
- Creating a Meteor Up Project
- Example File
- Setting Up a Server
- Deploying an App
- Build Options
- Additional Setup/Deploy Information
- Accessing the Database
- Multiple Deployments
- Updating
- Single command server setup
- Single command deployment
- Multi server deployment (Working in Progress)
- Environment Variables management
- Password or Private Key(pem) based server authentication
- Access, logs from the terminal (supports log tailing)
- Read, backup complete logs (Working in Progress)
npm install -g meteor-passenger
cd my-app-folder
mkdir .deploy
cd .deploy
runmeteor init
This will create a runmeteor.js
Meteor Up configuration file in your Meteor Up project directory
module.exports = {
servers: {
one: {
host: '192.168.12.25',
username: 'root'
// pem:
// password:
// or leave blank for authenticate from ssh-agent
}
},
meteor: {
name: 'app',
path: '../app',
servers: {
one: {}
},
buildOptions: {
serverOnly: true,
},
env: {
ROOT_URL: 'app.com',
MONGO_URL: 'mongodb://localhost/meteor'
}
},
mongo: {
oplog: true,
port: 27017,
servers: {
one: {},
},
},
};
runmeteor setup (best run this command as a super - sudo runmeteor setup)
This will setup the server for the deployments. It will take around 2-5 minutes depending on the server's performance and network availability.
runmeteor deploy (best run this command as a super - sudo runmeteor deploy)
This will bundle the Meteor project and deploy it to the server. Bundling process is exactly how meteor deploy
does it.
runmeteor reconfig
- reconfigure app with new environment variables and Meteor settingsrunmeteor stop
- stop the apprunmeteor start
- start the apprunmeteor restart
- restart the apprunmeteor logs
- get logs
When building the meteor app, we can invoke few options. So, you can mention them in mup.js
like this:
...
meteor: {
buildOptions: {
// build with the debug mode on
debug: true,
// mobile setting for cordova apps
mobileSettings: {
public: {
'meteor-up': 'rocks',
}
},
// executable used to build the meteor project
// you can set a local repo path if needed
executable: 'meteor',
}
}
...
This only tested with Mac/Linux
It's common to use paraphrase enabled SSH keys to add an extra layer of protection to your SSH keys. You can use those keys with mup
too. In order to do that, you need to use a ssh-agent
.
Here's the process:
- First remove your
pem
field from therunmeteor.js
. So, yourrunmeteor.js
only has the username and host only. - Then start a ssh agent with
eval $(ssh-agent)
- Then add your ssh key with
ssh-add <path-to-key>
- Then you'll be asked to enter the paraphrase to the key
- After that simply invoke
runmeteor
commands and they'll just work - Once you've deployed your app kill the ssh agent with
ssh-agent -k
If your username is root
or using AWS EC2, you don't need to follow these steps
Please ensure your key file (pem) is not protected by a passphrase. Also the setup process will require NOPASSWD access to sudo. (Since Meteor needs port 80, sudo access is required.)
Make sure you also add your ssh key to the /YOUR_USERNAME/.ssh/authorized_keys
list
You can add your user to the sudo group:
sudo adduser *username* sudo
And you also need to add NOPASSWD to the sudoers file:
sudo visudo
# replace this line
%sudo ALL=(ALL) ALL
# by this line
%sudo ALL=(ALL) NOPASSWD:ALL
When this process is not working you might encounter the following error:
'sudo: no tty present and no askpass program specified'
Meteor Up uses Phusion Passenger to run and manage your app. Here's how we manage and utilize the server.
-
your currently running meteor bundle lives at
/opt/<appName>/current
. -
we've a demonized passenger container running the above bundle.
-
logs are maintained via Phusion Passenger and available at /opt//passenger.log.
-
if you decided to use MongoDB,
mongo
It's bound to the local interface and port
27017
-
the database is named
<appName>
[Working In Progress]
You can access the MongoDB from the outside the server. To access the MongoDB shell you need to log into your server via SSH first and then run the following command:
mongo <appName>
[Working In Progress]
It's pretty okay to change the appName
. But before you do so, you need to stop the project with older appName
To update mup
to the latest version, just type:
npm update meteor-passenger -g
You should try and keep mup
up to date in order to keep up with the latest Meteor changes.