Check if my Nodejs server is running remotely - node.js

I have a Nodejs server running a website remotely in a Windows 10 machine. But the machine is sometimes turned off and I do not know that the website is down.
I was thinking of creating a Nodejs website and have it run in Heroku that sends a request to my website running in the windows machine every 5 minutes and notify me via email if it does not get a response. However, I wanted to know if there are better options available for situations like these.

Related

Deploy a node js application on fedora workstation 36

I have a nodejs application that i wanted to deploy on a local server(which is running Fedora 36). I have developed the NodeJS side on another pc,and it works fine when the node is running. But when i copy the node server directory to the fedora serve and run it,it only works on local host. I couldnot access the server even if i'm in the same network.
I'm developing the app for a small locally connected PC and i donot want to use the hosting companies as well as Heroku. Is the it the firewall that is blocking my request to the server? What option do i have to host it locally? Is there a better way?
Your node.js server is running on a port determined at the end of the script usually. Sometimes 3000. but can be anything. The correct way for others to access is as you say...
http://your.network.ip.address:port/
or
example ip
http://192.168.0.3:3000
check your local ip and port where you run this server.
How could others, on a local network, access my NodeJS app while it's running on my machine?

using VPS(Ubuntu) to create server using google calendar API authentication failed

So I am doing this project. I'm basically creating this server using task warrior and google calendar API to upload tasks that are made from the terminal to the google calendar.
Originally I did this on my personal computer(OS archlinux) and it worked, but I can't keep my computer running 24/7 so that why I opted of using a VPS. The VPS is running Ubuntu 20.04 without GUI. The same process that I did on my computer I to the server, everything went well until the part where google asked to allow the program to which I got a localhost refuse to connect message.
I'm going to assume that because it isn't my local network it going to refuse the connection.
My question how to allow that connection to be accepted by google? Is it something that I need to add or change in the API setting on google?

How to use Redis / Node.Js on a production server

I get what Redis and Node.js are but i don't understand how to run them on a live server. Locally its an install and you use the command line to get them running but i don't know how to install them on a live server.
I've already browsed around a bit but im still confused and also isn't Node.JS a server itself so its like running a server on a server? wouldn't that have effects on performance and what not?
I'm just confused on how it would work, any explanation will be great.. thanks
Redis & Node.js = Software
You install those on a physical machine, a computer. A node.js server is not a physical server, but an application that can handle HTTP requests. Normally, a node.js server runs on a port on a physical machine. So any HTTP requests sent to that port are handled by the node.js application. You can use a webserver, which is another piece of software that handles HTTP requests, like Nginx or Apache to manage multiple domains on a physical machine (the server). Redis also runs on a physical machine and listens on a specified port.
For example, I have a VPS with 4 websites on it managed by Nginx. Two of those websites are Laravel projects that connect to a MySQL server (on another machine) and to a Redis server on the same machine. The other two are node.js applications which don't need a database or Redis, so they just listen on their own ports and Nginx proxies all connections to their domainnames to those ports.
So you're not actually running a server on a server, but you're running software that handles certain things on a server.
There are different ways to run a node service. I strongly recommend docker to run everything but here is a short list of the most popular ones:
https://www.docker.com/ https://hub.docker.com/_/node/
http://pm2.keymetrics.io/
https://www.npmjs.com/package/forever (seems like a bit outdated)

NodeJS app running on VPS (linux) crashes when I put my laptop to sleep

I absolutely 100% new to VPS and linux as of yesterday, and I'm running into an issue. Here's the process:
I SSH into my VPS box in OSX terminal. The VPS is running CentOS 6 for what it's worth.
I navigate to the correct folder and I run node app.js to launch my app in NodeJS/ExpressJS.
App launches and is readily accessible via the web at my VPS' ip address + the allocated port number.
If I put my laptop to sleep, the app crashes and is no longer accessible via web.
Again, being new to Linux I'm not sure how to solve this problem. It makes sense, as the terminal that was running/taking logs of the node app is no longer responding, but what I'd like is:
a) To be able to start up the app remotely then have it just...run...forever, until I manually stop it
b) To be able to SSH back into my server intermittently to check the logs, either via my mobile phone or my laptop.
Are either of these two things possible? Clearly my protocol of launching the app via terminal (as I'd normally do if running it locally) isn't the correct way to do it but I'm having trouble finding resources telling me what to do!
EDIT: I'm actually using Node Supervisor to run the app which helps keep it up and running when things crash, not sure if that affects the situation.
Most probably your app is printing to standard out (the console), and that stream is closed/broken, when you put your laptop to sleep.
There are at least two options:
Use screen: Just type screen before starting your app. Then start your app. Then Ctrl-A-D to detach from the screen. You can then safely log out from the VPS and put your laptop to sleep. To go back to the output of your app, log back in and type screen -r
Run the app in the background: node app.js &.

Browser app to connect to several sshd

I would like to draft a browser application which can connect to ~20 remote sshd. Per ssh connection multiple commands should be handled. After restarting the browser, the several running jobs should be displayed in the browser again.
How would you construct the application ? The application should run on a Raspberry Pi. So utilization is limited.
Check the wikepedia page for web based SSH. The basic idea is to have JavaScript on client to submit commands to server side web application. And server side application will connect to several different server sshd as proxy to send command and receive output.
Personally I will suggest to use WebSocket to implement the communication between client and server. But not sure what's the OS you will have and what library and programming language will be handy for you.

Resources