Meteor deployment guide to production

I had written a small write up while trying to upgrade my Meteor app in production. Hopefully it helps somebody who wants to control their deployment.

This is for folks who do not want to use Docker or Kubernetes or MUP …

Please check … https://github.com/pkumar-uk/meteor-deploy-prod-1.12.1

The Meteor App is at 1.12.1 version, MongoDB 4.4, Redis Oplog and PM2, nginx

5 Likes

@perumalkuk
Hello, thank you very much for your good source.
Is it possible to put the mongodb usage guide on a server?
This means that meteor and mongodb software run on one server and do not require two servers.
I want to run the mongo service on the same main server.

Thank you. I think it is very easy to use this as a reference for one server setup.

The MongoDB installation is going to be almost the same, except for the following:

  • No need to open up port 27017 in ufw
  • There is no need to bind the server ip in mongod.conf
  • 127.0.0.1 used as the ip address for MongoDB server
1 Like

I do the same thing, but I run into problems like this

Check from the server if you are able to access mongodb server using mongo shell. also check the replication status using the mongo shell (rs.status())

Finally instead of localhost replace it with 127.0.0.1 and check if it works

@perumalkuk I went through exactly these steps but I get this error

MongoParseError: No hostname or hostnames provided in connection string

Error clearly shows MONGO_URL is not correct. Sorry too little information to help you.

You should check if your pm2.json is correct …

Did you follow the steps …is mongodb running?

this is my pm2.json :

{
  "apps": [
    {
      "name": "ghadr",
      "cwd": "/home/Ghadr/bundle",
      "script": "main.js",
      "instances":1,
      "env": {
        "NODE_ENV": "production",
        "WORKER_ID": "0",
        "PORT": "3000",
        
        "ROOT_URL": "http://193.105.234.244",
        "MONGO_URL": "mongodb://127.0.0.1 :27017/meteor",
        "MONGO_OPLOG_URL": "mongodb:// 127.0.0.1 :27017/local",
        "HTTP_FORWARDED_COUNT": "1",
        "MAIL_URL": "",
        "METEOR_SETTINGS": {
          "public": {
            "MainUrl" : "http://193.105.234.244/"
          },
          "private": {
              "kavenegarKey" : "574A516A436E357646684D414A325A673769477A73383331447A5872676C727A58434E4869474453346D4D3D"
          },
          "PrerenderIO": {
              "serviceUrl": "http://localhost:3030/",
              "token": "nothing"
          }
        }
      }
    }

  ]
}

@perumalkuk To install Mongo DB, I followed exactly the following steps :

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod.service
sudo systemctl enable mongod

sudo nano /etc/mongod.conf  and i append this : 
          replication:
               replSetName: meteor

sudo systemctl restart mongod
mongo
var config = {_id: "meteor", members: [{_id: 0, host: "127.0.0.1:27017"}]}
rs.initiate(config)
sudo systemctl restart mongod


There is space between 127.0.0.1 and :27017 ----- there should not be any space

is error again :

and this is pm2.json :

@perumalkuk Do I have to run with a non-root user?

Still there is a space in MONGO_OPLOG_URL check…parameters are sensitive and need to be type exactly …and error messages are always hinting the error…you need to analyse your logs rather than post each time you encounter error