Hi folks, do you have any experience in running meteor with pm2. I owuld just simply want to run my meteor app on DO droplet like i run simple node servers. I found pm2-meteor - npm. But seems it is out of maintenance and provides many things i would never use. Is there any way as simple as pm2 start index.js
i used to run in simple node scenarios? Thx in advance.
Hello, we are using pm2 like this :
NVM_DIR=__deployPath__/.nvm NODE_ENV=production pm2 start bundle/main.js --name __deployName__
where deployPath is the path to your app and deployName is your app name
You can also use a file to describe all env variables and meteor settings
Regards
Check out this link https://github.com/pkumar-uk/meteor-deploy-prod-1.12.1 for using PM2 with meteor
Take a look at my in depth guide for running Meteor on PM2:
https://jamesloper.com/meteor-deployments-without-mup
Iām still using pm2-meteor on multiple apps, and very happy with it. Once you have the config-file which takes care of the env-vars, itās a single command to deploy.
Hi @james. Nice work. Anyways maybe you know what is the reason of error i got. Build works fine then it properly uploads, but during execution remote script i got :
0|staging | Error: Cannot find module 'reify/lib/runtime'
0|staging | Require stack:
0|staging | - /home/ubuntu/staging/bundle/programs/server/runtime.js
0|staging | - /home/ubuntu/staging/bundle/main.js
0|staging | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
0|staging | at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:61:29)
0|staging | at require (internal/modules/cjs/helpers.js:74:18)
0|staging | at Object.<anonymous> (/home/ubuntu/staging/bundle/programs/server/runtime.js:10:3)
0|staging | at Object.<anonymous> (/home/ubuntu/staging/bundle/programs/server/runtime.js:53:3)
0|staging | at Module._compile (internal/modules/cjs/loader.js:999:30)
0|staging | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
0|staging | at Module.load (internal/modules/cjs/loader.js:863:32)
0|staging | at Function.Module._load (internal/modules/cjs/loader.js:708:14)
0|staging | at Module.require (internal/modules/cjs/loader.js:887:19) {
0|staging | code: 'MODULE_NOT_FOUND',
0|staging | requireStack: [
0|staging | '/home/ubuntu/staging/bundle/programs/server/runtime.js',
0|staging | '/home/ubuntu/staging/bundle/main.js'
0|staging | ]
0|staging | }
When it comes to binaries, I think there are still some problems even with my script. For my deployment I had to add some more stuff inside remote-script.sh
echo "Installing npm packages"
cd bundle/programs/server
rm -rf node_modules/sharp/vendor
rm -rf npm/node_modules/sharp/vendor
rm -rf node_modules/mozjpeg/vendor
rm -rf npm/node_modules/mozjpeg/vendor
meteor npm install --production &> /dev/null
I looked at reify on npm and donāt see any reference to a bundled binary but you could maybe try this on your remote script.
echo "Installing npm packages"
cd bundle/programs/server
rm -rf node_modules/reify/vendor
rm -rf npm/node_modules/reify/vendor
meteor npm install --production &> /dev/null
i solved it temporary by going there and manually run ānpm installā anyways i now see another problem that it seems to have problem with env.sh. I see now āMONGO_URL must be set in environmentā While it is set in env.sh.
It must be something wrong with meteor it self because even if i go there and manuall run.
MONGO_URL=my_mongo_url ROOT_URL=..my_root_rl node main.js
It shows the same error. While obviously MONGO_URL
is provided.
More intresting is fact that it you placesome shit in MONGO_URL
like MONGO_URL=blahblah
it properly tells that connection string is invalid.
You have any special chars? Try wrapping it in quotes likeā¦
export MONGO_URL="mongodb://app:password@db.jamesloper.com:27017/test"
Yep this was solution. However this is definietly bug in meteor, problem should be reported properly. Anyways now it says " MongoError: setName from ismaster does not match provided connection setName [atlas-nyb1n1-shard-0] != [example-staging-shard-0]" but when i deploy using your script, kill the app and then ssh to the server and manually run it there from command line it works. Interesting. I will let know if i will find something.