0

I have a nodejs webapp that connects as a client to a websocket and sends me push notifications whenever certain events occur. It also has functionality to send requests to a REST API based on information received from the same websocket.

So far I have been running this app locally and keeping my laptop on at all times. But soon I am going to be traveling so keeping the laptop on 24x7 is no more an option.

What can I do such that I will be able to run this app 24x7 (since it must be connected to the websocket at all times) without having to keep my laptop running?

The only option I can think of is to run the app locally on a Digital Ocean Droplet and then RDP into the droplet whenever I need to use it. This way it runs 24x7 and I can access it whenever I want by RDPing into the droplet. The only concern I have is if the cheaper droplets will be powerful enough to allow me to RDP into them and use the app without lag.

This app does not need to be access on the web. Would bundling it as an Electron app and then running it on a remote server be considered better practise than just running it at 127.0.0.1?

Appreciate your inputs.

Thank You!

philosopher
  • 101
  • 1

1 Answers1

0

Yes, running the program on a server is pretty much what you do, in such cases.

I can recommend the Non-Sucking Service Manager (https://nssm.cc/) to ensure the program stays running.

As for making it run well on a cheap server instance: Turning it into an Electron app will add a couple of hundred megabytes of bloat and an entire new runtime environment to your program.

If bang for the buck is important, can you interact with the web app using only HTTP GET and POST commands rather than running a local web browser on the server? Unless your program requires a GUI to function, there are viable alternatives to running a full desktop enabled Windows server, which can cut down on running costs a little bit:

  • If you’re not afraid of the Windows commandline or Powershell, you can save a lot of bloat by running a Windows Server Core installation. If your cloud provider supports running the latest Windows versions you even have native support for ssh, so you don’t need to RDP into the server (although my experience is that you have other problems if that protocol is too slow to be usable).
  • An alternative might be to not run Windows at all. This may save you yet another little bit of overhead even compared to Windows Server Core.

(If you do decide to allow RDP, take measures to allow access only via VPN, or at most only from specific known IP addresses. This is not a protocol that was designed to be securely presented to the Internet.)

Mikael H
  • 4,868
  • 2
  • 8
  • 15
  • Thanks for the reply Mikael. In that case, I won't use electron since I want the app to be as lightweight as possible. Part of functionality of the app depends on a GUI to function. I could create an API (and authentication) for the app so that it can be used without the GUI. (1) Is this the route you are suggesting? (2) If I do want to use the GUI of my app, is it necessary to use Windows? With DO Linux droplets, you can use the VNC (equivalent of RDP) protocol to access the droplet GUI. (3) Final question, is it not safe for access my Linux droplet using VNC? – philosopher Oct 13 '19 at 13:26
  • 1) A GUI-less application tends to be more lightweight than one that requires a GUI. If it’s a web app anyway, perhaps it can work using only the web API? 2) If you’re going to use a GUI anyway, I don’t see much point in porting the GUI part of the app to Linux if you already have it working in Windows. 3) Like with RDP I wouldn’t personally present VNC untunneled to the Internet. A management VPN is usually the best idea, followed by plain ssh (as long as you drop username/password authentication and use PKI authentication instead). – Mikael H Oct 13 '19 at 16:31
  • Thanks! (1) Can you explain what you mean by, 'it can only work using web API'? The app has an html page where I enter values and execute time sensitive commands (has to be done manually and cannot be automated). (2) The app was developed on MacOS so porting to Linux is not that much of a problem. (3) Thanks! This part I understand. Do you have a link which elaborates on the security risks of using naked VNC? – philosopher Oct 13 '19 at 16:47
  • Re (1): Depending on how the page was written, it may be relatively easy to curl (or the Windows equivalent) data to/from it from a command line rather than via a local web browser, which would lower the performance demands on the server considerably. As you wrote, you could also present the web app (if you trust its security) to another computer, which could allow you to keep using a web browser to control the app without affecting the performance of the web server. – Mikael H Oct 14 '19 at 08:39
  • 1
    Hey, so I figured it out. Basically, after the app is hosted and running on a server, I can access it via an SSH tunnel to the server. Thanks for your help! – philosopher Oct 14 '19 at 13:19