I'm new to PM2 and nodejs, I'm trying to learn node by following simple sample that creates a server that displays 'Hello World' from the browser. Please note that I'm running node on QNAP NAS. I have successfully installed nodejs, npm, and pm2. when I run app.js via node app.js, it works and I see the message using the port specified.
but when I run via pm2 start app.js, I got this
Then after a few seconds I got status = errored
when I look at the log I got this.
I tried searching in google but the result were pointing to old version of node which I don't
Node itself has to be built with inspector. You can try to install LTS version of node.
Alternatively, you can try installing node-inspector with npm i node-inspector --save
Related
I am new for Nodejs. I have developed an application using Expressjs. Now I want to deploy my app to the server and I already bought a server from digitalocean.
I don't have any idea that how to deploy my app via PM2.
Please help..
if you have installed nodejs and pm2 on your server. you just need to run pm2 with your express js application instance.
pm2 start bin/www
You can find your express js application instance in the package.json file. see in the screenshot below.
after that, you can run the command to check the running instance of the application.
pm2 ls
After you install nodejs to your server, first you need to install pm2 globally via npm:
sudo npm install pm2 -g
Then, just run the start command:
pm2 start "/path/app.js"
Thats it. You can see the project with: pm2 status
For more pm2 code I suggest you to take a look at https://www.npmjs.com/package/pm2
See directly the PM2 deployment page : http://pm2.keymetrics.io/docs/usage/deployment/
You just set the configuration of your server host,user,git etc... and pm2 will deploy it remotly automatically
What is the best practice for using Phusion Passenger with a version of node installed my nvm?
In this tutorial on using Passenger to run a Meteor app, I read:
[Y]our Meteor application is run as ... the owner of the
main.js file (when deploying a Meteor bundle), unless you configure it
otherwise. Of course you still have to make sure that each of your
applications is owned by another user.
Meteor 1.6 works with Node.js v8.8.1, so I have used nvm to install node. I created a special meteor user to run the nvm installation of node and nvm. Node was therefore installed at /home/meteor/.nvm/versions/node/v8.8.1/bin/node, and /home/meteor/.nvm/versions/node/v8.8.1/bin/ was added to the $PATH variable for my meteor user. As a result, calling node -v as the meteor user showed that v8.8.1 was installed and accessible.
I followed this tutorial to deploy my Meteor app to my server.
As the meteor user from within the bundle/programs/server directory, I ran npm install --production. I made meteor the owner of everthing inside bundle/.
I had expected that Passenger would launch node as the meteor user, and that everything would run smoothly. Instead, Passenger showed a useful alert page, apologising that "something went wrong".
To work around this, I created a symlink at /usr/bin/node to point at /home/meteor/.nvm/versions/node/v8.8.1/bin/node, and now Passenger was happy to launch the bundled app.
This suggests to me that Passenger was not running main.js as the meteor user. Or is there another reason why the meteor user was not able to see its own version of node?
The quote above suggests that it is possible to configure which user Passenger uses. How do I do that?
In a nutshell: what is the official Passenger method for working with a version of node installed by nvm?
You'll want to set the version of node to the full path to the nvm node: https://www.phusionpassenger.com/library/config/standalone/reference/#--nodejs-nodejs
As for the user-switching, you can set the log-level to 7 (https://www.phusionpassenger.com/library/config/standalone/reference/#--log-level-log_level) in order to debug that and either go through the startup logs yourself or post them here.
I know I can run Node.js on server with command line node app.js.
But when I am out of control server, the session will be close and end my command. I don't know how to make a service run Node.js 24/7 like another in Server.
I follow this post, but I'm not using express.
run it using forever , it helps the server to restart whenever the node server get crashed. https://www.npmjs.com/package/forever
You can make it happen by many ways.
You can append & in the command line to make the node server run in background.
node app.js > stdout.txt > stderr.txt &
Via process manager pm2, It gives more features, you can monitor all the processes pm2 monit, auto restart, etc
npm install pm2 -g
pm2 start app.js
or, using following npm packages
Nodemon - nodemon app.js
Forever - forever start app.js.
My environment is ubuntu 16.04 with npm 5.0.0 and node 8.0.0 installed. I created an express application and started it with nohup npm start & in the application root directory. However, a couple of minutes later the app became unreachable and the process was lost. I tried restarting several time but the process always automatically exits. How can I start a long-running nodejs app?
Use pm2 daemon for setting Up a Node.js Application for Production on Ubuntu 16.04
Follow commands
sudo npm install -g pm2
pm2 start server.js //Yor main node server.js
pm2 stop server //no need of giving .js , .js only required at start of process
pm2 restart server //for any changes are done to restart
For more You can follow digital ocean tutorials for more details from below link
Digital_Ocean_Link
i have installed meteor js but when i going to run any app using command meteor it gives me an error like this.
'/home/user2/.meteor' exists, but '/home/user2/.meteor/meteor' is not executable. Remove it and try again.
snapshot