I am in need to manage my node server without entering into server console. I have tried using forever, nodemon and pm2 npms. Whenever, I need to start or stop the node application, I need to connect the server via terminal. I want to avoid that and willing to see the possibility if that can be managed through any web interface or any browser plugin/extension.
Already tried forever, nodemon and pm2
You can use npm pm2-gui install it by this command npm i pm2-gui
See the docs and guides from here https://www.npmjs.com/package/pm2-gui
I started looking for some GUI and Web interface of PM2. Tried several npms but "mc-pm2-web" worked really good for me.
I am using Node via NVM and my node version was v10.15.3. Installed this https://www.npmjs.com/package/mc-pm2-web and it was straight forward what I was actually looking for.
Here's are the step if anybody wants to install and configure "mc-pm2-web" in AWS EC2.
I am using Amazon Linux
I am using NVM and running v10.15.3
Already had NGINX & PHP-FPM running on server using port 9000
pm2 already installed
Visit this link:
https://www.npmjs.com/package/mc-pm2-web
npm install -g pm2-web
pm2-web
If you encountered any error then you may check your config.json file. In my case the config file path was:
/home/ec2-user/.nvm/versions/node/v10.15.3/bin/pm2-web/config.json
I made following changes in config file to make it working:
Port from 9000 to 9010 because 9000 was being used by PHP-FPM
Changed the host name from "localhost" to "my-domain" which was already hosted in NGINX
Enabled authentication and set the Username and Password for making it secure
Allowed 9010 port from AWS EC2 firewall / security group of that instance
Added pm2-web in pm2 by executing "pm2 start pm2-web" command
Related
Sorry maybe it is a dump question but I could not go further.
I got a website which already built with ReactJS and working on AWS Ec2
When I run on localhost
First; in terminal which in file directory run node server.js
yarn start
then I can see the localhost:3000 then when I make any changing just send with SSH and run server with PM2 which pm2 restart server
My question is I want to create a second AWS EC2 instance and run the code there as well when I change config.json which domain is store there I can see a NETWORK ERROR
I created a ec2 instance copied all my files there and I installed NodeJS npm and pm2 but I could not managed see my website on localhost:3000()
What Do I have to do?
You need to use the EC2 public address/IP not localhost
I have developed a simple node.js application and I am trying to publish it on AWS Lightsail. I followed the instructions on this page: https://medium.com/#sharmasha2nk/aws-lightsail-bitnami-nodejs-letsencrypt-cf653573b8a1
I am connecting to Bitnami using the SHH console provided. After I start the app with node index.js command the app is up and running until I close the SHH console. As soon as I close it the application stops and “Service Unavailable” error is being displayed. How can I keep my app running on AWS even if my PC is shot down and the SHH console is closed?
I have tried restarting the apache server and AWS Lightsail instance. Neither of them helped.
httpd-app.conf file content:
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
httpd-prefix.conf file content:
Include "/opt/bitnami/apps/emsnotes/conf/httpd-app.conf"
Thanks.
I would recommend you pm2
Here's how to do it quickly:
install pm2 globally using sudo npm i -g pm2
navigate to the location of your index.js via ssh
run pm2 start index.js
This will keep node running even when you disconnect the ssh session or shutdown your development computer. The process will keep running on your server in the background. This is used for running node apps in production on a server.
You can read all about it here in its documentation.
I hope I could help you, please let me know if you have any question.
Karim
I had a look at the article and frankly i see nowhere that he talk about keeping the server up and running.
Basically he is using the Bitnami Node.js stack and if you look at the docs you will see that Bitnami use Forever.js to keep the apps running on their instance, Forever is a CLI tool to monitor and keep a Node instance running in the background.
Check the docs here : https://docs.bitnami.com/general/infrastructure/nodejs/administration/start-express-server/
Here is the Git for Forever, so can read more on it: https://github.com/foreverjs/forever
I'm pretty new to DevOps and I'm trying to set up my Node.js app on a AWS server instance. Steps I've taken:
Set up Elastic IP
Launched EC2 instance with Ubuntu server
Connected IP to instance
Allowed incoming connections on port 3000
SSH'd into the server with a .pem file
Now I'm at the point where I need to get my files uploaded to the server. I've used FileZilla (and like it) in the past to upload files but the initial part was already set up. When I set up the site on FileZilla there is no /var/www folder on the remote site.
Don't know how to connect these dots.
Also not sure what I need to run once I successfully upload the files. I imagine npm install when I'm ssh'd into the server? Most of the tutorials out there only go through the basic instance setup.
Thanks!
You don't need to have /var/www. Also, it's better that you use a version control and a remote repository like Github and then SSH to your EC2 and then clone your repository there.
Then cd into your repo and run npm install and then start your app.
And check.
Once you connect to the EC2 instance then clone your code in there. It not mandatory to be in /var/www/html but, it's best practice to keep it there. Once you clone npm install into your project home directory so all the required packages get installed. Then for running your node application in production you have to run it on service as pm2, supervisor, forever, passenger, etc. You can use any of these services and configured appropriately to run your application on desired port. As with pm2, you can follow this guide, install pm2 Then you can run with the following command w.r.t. your environment, like I want to run my application on port 5555 for production
$ PORT=5555 pm2 start app.js --name API --env production -f
Check the status using pm2 list Now, your application is running on http://server-ip:5555/ But, you won't be typing port number every-time. So, you need to configure the web server in front of your application like apache or nginx which will forward all request to your application running port. You could find the best guide to their home page. Then your application is available at http://server-ip/ You can follow this for single configuration of multiple node apps
Hope this helps.
I have created node application and I want to deploy it on AWS.
I have setup project and want to make node permanent so I have installed pm2 globally, but when I tried to start node app with pm2 with this command
sudo pm2 start index.js
It's giving me error:
sudo:pm2 is not a command
Without sudo I can't start server.
Apparently pm2, and other global modules aren't in your root path. You can pass the PATH variable like this:
sudo env PATH=$PATH pm2 start index.js
This should do what you want.
Though mainly I would suggest not doing this, as probably you wouldn't want your application to run with root user, rather it's own isolated and limited user so in case vulnerabilities, the damage would be limited.
If you want to run pm2 on your machine startup, then you can use pm2 startup command which will instruct you how to do this properly.
Also if you are running your application as root, so you can listen on port 80, then that's the wrong way. I suggest have a look at this question. There are some good suggestions such as using ip tables to forwad port 80 traffic to another port which wouldn't require your application running on root.
Refer to https://github.com/openfin/process-manager
Based on the README.md, I have done the following steps:
npm install
node server
I am able to see the following message from terminal(windows 7)
$ node server
Express server listening on port 5040
How do I launch the application?
I have tried to point to the localhost:5040 through chrome browser and ONLY see three tabs 'Processes', 'Cache', 'Logs' without any information.
How can I fix the issues?
npm i -g openfin-cli
openfin -l -c http://localhost:5040/app_local.json
The server script is running a local express server that hosts an OpenFin enriched web app so all you need to do it launch it on OpenFin, which in the case above we are doing with the CLI.
You can also use a node module to launch i.e. here