Lighsail Bitnami MEAN Stack Application Continuous Running - javascript

I have an MEAN application running on server through Amazon Lightsail. I installed my application in the /projects folder and once I ssh onto the server and run node bin/www (where my main startup scripts live) the site runs perfectly. The issue comes once I close the ssh shell the site goes down (node stops running). Does lightsail / AWS provide any utilities to keep up the server or do I need to manually install a service that keeps it up so I can point a domain at the IP and it is consistently running?

Related

Excel Javascript Add-in Deployment On Local Network

I have developed an Excel Javascript Add-in on my machine using the yeoman generator. The add-in itself works fine when I start it up on my client with npm start. I can use the add-in on any port I want provided I change all the ports in the config files etc. However, we now want to delpoy this add-in on our local server to make it available to several users.
I have noticed that every time I change the location of the project e.g. from my machine to the server the application will start up but Excel will give me the error message "ADD-IN ERROR Sorry, we can't load the add-in. Please make sure you have network and/or Internet connectivity. Click "Retry" once you are back online". My work around for now is to create a new app on the server and copy the html, js and css file to the taskpane folder. When I now start up the new app it'll work fine.
For the second issue I haven't found a solution/understood the behaviour. When I create an app with the yeoman generator on our server (MS server 2019) and start it up it can be reached via e.g. localhost:3000 on the server but not via :3000 or :3000. It runs fine when I access it from the server itself.
I have opened the inbound and outbound port 3000 on the server to allow https communication. In a next step I added the manifest to the windows 365 admin console and added myself as user. When I open Excel from my machine (client side) the excel add-in will be available in the insert ribbon but won't load and I get the same error message as described above "ADD-IN ERROR Sorry, we can't load the add-in. Please make sure you have network and/or Internet connectivity. Click "Retry" once you are back online"
The following troubleshooting steps have been performed. I checked whether I can reach the add-in url via web browser but the connection timed out. When I check on the server side whether the app is listening I get the below result.
TCP 127.0.0.1:3000 0.0.0.0 Listening 40776
I'm not sure but I think the app should list on e.g. 0.0.0.0:3000 to capture inbound traffic from the client side. Is there a way to change this add-in (app) behaviour on the server when creating/starting up the app with the yeoman generator? I have checked the webpack.config.js file but I couldn't find any way to change that behaviour.
Any idea/help is appreciated.
Thanks!
I believe this is precisely the intended configuration of the yeoman development environment. It spins up the webpack dev (NodeJS) server, which by default only listens to the localhost / loopback address.
From here:
https://webpack.js.org/configuration/dev-server/#devserverhost
It looks like you could hand modify your webpack.config.js file to include a
host: '0.0.0.0' entry under the devServer listing.
The other item you might need to change is
https://webpack.js.org/configuration/dev-server/#devserverallowedhosts
As I believe this defaults to 'auto' which would only allow connections from the local computer.

how can I connect to a http://localhost:4200 using browser which is a aws ec2

I am learning node.js in an online course to build up a web server and app
before the teaching started, the teacher told me to set up your coding environment, and it got a direction to told me what to do step by step.
Because I using Chromebook, So I started an aws ec2 serve which is ubuntu 18.04 and using cloud9 for my ide
I installed node.js successful on the ec2
And the direction told me to type on those on the terminal
git clone https://github.com/OpenClassrooms-Student-Center/5614116-front-end-app.git frontend
You can then do the following:
cd frontend
npm install
ng serve
This will install all the dependencies needed by the front end app and will launch the development server. Now, if you navigate to http://localhost:4200 , you should see the following (assuming you've followed the steps above successfully):
the direction say if I successfully followed the step, will see something on http://localhost:4200
On the terminal, at last show me
ℹ 「wdm」: Compiled successfully.
But how can I connect to http://localhost:4200 which was an ec2?
I tried using IP:4200, the browser keeps on loading the page and nothing shows up on the browser
----------------------------------------
I found out that the program that teacher gave me to install set the URL to http://localhost:4200
because cloud9 says the program was running, but running at a URL call http://localhost:4200
what should I do?
Localhost refers to your local machine. But as mentionedd that your node.js running on ec2 and want to connect to it from your browser, get the IP of the ec2 and type in your browser- IP:4200
And it should work
The only problem here is you have to add port 4200 in your aws ec2 instance security group to allow inbound traffic.
STEPS:
1. Go to your EC2 instance.
2. Click security group from Description below.
3. Click Inbound then Edit.
4. Click Add Rule
5. Select Custom TCP , Port - 4200 , IP - 0.0.0.0/0
6. Then SAVE.
After that try <EC2-IP:Port> in your browser it will work fine.

Web console for docker container

Situation
There is a data-only-container named: app-data
There is a copier container worker
Initially app/data was created and that's it, it's status is 'stop' / exited.
Then the copier worker copies some files to app/data as its volume, for example an server.py
Okay this was done like this:
docker run --rm --volumes-from app-data /somelocation/server.py ~/www/
the copier takes 2 arguments, the file to copy and where to copy
With that at hand, I can run a image named app/serve to server the file in the volume like so:
docker run --volumes-from app-data -d -P app/serve
the image entry point do this http-server, and workdir is same as the data volume, so it'll run
Hell yeah it works, and the python web app can be accessed in the host with a highport like so: 0.0.0.0:49124 because
the app/serve image expose ports 5000 which is used by the sever.py script
I had the above working, you can focus below.
So the app can run huh? But I want to do more complex things that just running the app (I ran the app using the remote api), what if I want to run the app using a web console connected to a docker container.
My Idea of how would it be possible
use term.js
expose 2 ports e.g. (4000, 5000)
use port 4000, so that when term.js executes in port 4000, it'll generate a highport for the client to use in the web console socket connection
use port 5000 to allow whatever web application ran in port 5000 will be available in a another highport, to be accessed like so 0.0.0.0:49124
This is a prototype implementation of how runnable/dockworker do this, I am still new to nodejs that is why I cannot comprehend how they do it, could there be a less-featured simpler execution of this idea?

Node.js on Amazon AWS goes down when Putty SSH is disconnected

I just set up my first Amazon AWS server, with a Node.js installation on it. I run my app, at which point Node says that it's listening on port 3000. However, if I close my laptop, Node.js is no longer reachable through my app. How can I make it run even when I'm not logged in to the server through Putty? As a follow-up question, how can I re-open the Node instance (so that I see the any console.log messages from it) when I log back in to my server?
Thank you!
This is part StackOverflow, part Serverfault question I believe. It sounds like the problem is you're running the node server in the foreground of your SSH session, but you'd rather run it like a service (in the background).
When you exec something like that simple node server, you're running it (by default) in your SSH connection, which ends when your connection terminates from sleeping your computer. Some scripts/programs will run by default in the background, but if you're seeing results in STDOUT (printing to the shell) it is running in the foreground.
Highjacking these answers: Node.js as a background service
Two solutions
*nix solution: http://en.wikipedia.org/wiki/Nohup
Node solution: https://github.com/nodejitsu/forever

Installing NodeJS and SocketIO in a Remote Server

My project is a Real Time Two-Player Facebook Game, and what I need is a tool that will help me build the game with quick responses to enable the "Real Time" function of the game. I have just found out about the Node JS and Socket IO. I have some knowledge in JavaScript so I stepped up and watched a few tutorials that discuss the functions of Node JS and Socket IO.
Here's the link to the videos that I have watched:
http://www.youtube.com/watch?v=mSE6xHkcX0w
I understand the basic of the Node JS and Socket IO and successfully installed it in my localhost. The problem is when I uploaded the files from my localhost to my remote server, some functions of the program are not working well. I don't know how to node my JavaScript file when it is on the server, because if it's in my localhost, I am using command prompt to run it.
node app.js
Node is not a web framework.
Chances are, you're using a web host that's generalized for web frameworks like PHP and Ruby on Rails. You're going to need virtual private server hosting, or Node-specific hosting, because Node requires a virtual machine to run. You otherwise won't be able to run Node Package Manager or Node itself.
Joyent has provided a list of hosts here.
If you chose to use a VPS or dedicated machine, an installation guide would be found here. This is how you would install Node on CentOS.
wget http://nodejs.org/dist/v<version>/node-v<version>.tar.gz
tar -zxf node-v<version>.tar.gz
cd node-v<version>
./configure
make -j <number of cores>
make install

Categories