Difficulty in deploying Node.JS + Grunt based web application from terminal - javascript

I have a website which is developed based on Node.JS and uses grunt to be run.
I want to deploy it on my aws server. So, i installed node.js and all its dependencies and modules, configured database etc, and i am able to run it from terminal.
First i used
grunt build
and then
grunt
and website is running and up without any problem.
My question is that how should i deploy these kind of websites, so it always is running and listening to the port? That is because whenever i close the terminal (Putty), it will stop working.
I tried using these commands to run it in the background but didn't work :
grunt &
alnd also
(grunt &)
but whenever i exit the terminal (putty) , web server stops working.
Can anybody please help me with that? How can i make grunt running even after closing the terminal?
And how node js + grunt websites will be deployed on the server in general?

Related

Right way to do End to End tests with Jenkins

I have an app using PHP and ReactJS for the frontend. I have unit tests for the PHP project and e2e for the frontend project. I deploy my project using Jenkins and Docker for the app.
When a developer push on a branch, I'd like to run the tests (unit, e2e) in the CI. If everything is OK, we can deploy the project. I'd like to know the right way to do that ?
Today I am doing these steps :
one dev pushes the code, the job "test-app" is triggered in jenkins
the job build the docker image in a "dev" environment, with the dev dependencies in PHP
the app is started, let's say the url is "tests-app.com"
the tests are executed (unit, e2e using Selenium and tests-app.com)
the tests are OK, a job "app-deploy" is triggered and "tests-app.com" is shut down
the job app-deploy build the docker image in a "prod" environment, without the dev dependencies in PHP
the app is started the url is now "app.com"
Is that the right way to do that ? From the push by the developer and the end of the Jenkins builds it can take 5-10 minutes.

How can I prevent multiple applications being served at once by AngularCLI?

Using
Angular CLI: 1.5.2
Node: 6.10.1
in a Mac OS Sierra,
I have installed several web applications so far. Anytime I do ng serve. All of the applications that I have installed in the past are served.
I guess it's the normal behavior. But I don't need that...
How do I "uninstall" old applications that I don't want anymore to be run?
Edited to answer comments:
I run npm start from one of the applications that get served. Actually, I run it from the only application that I'd like to be started. However, as I said, all of the applications get started up.
Some other facts:
They run under the same port (4200).
The first application I installed runs without any context in the URI. (http://localhost:4200)
The rest of the applications are started under the same 4200 port, but I need to complete the URI with the actual context.

How to make an executable(.exe) that packages a nodejs server? (not UI-centric)

I have implemented a nodejs server that serves incoming requests to use the bluetooth services of the local computer. I want the nodejs server to be packed as an windows executable file so that I can distribute it. People should be able to just install/run that .exe which will install any packages required (if any) and run the server. How to do this?. I saw and tried node-webkit etc., but they are UI-centric, that is it can pack a nodejs application that opens a html page. But I want my server javascript file to be executed, like the way it is done in command prompt : node file-name.js. How to do this?
I've a server running with nodejs and for execute this I use a .bat file.
Create a .bat file
Inside of the file put:
cd path/to/server/
node índex.js
I used JXCore for this task in the past. It basically creates one executable that includes everything.
Unfortunately active development of is halted.
Solution:
You can use nexe for that.
Create a single executable out of your node.js app
Motivation
Ability to run multiple applications with different node.js runtimes.
Distributable binaries without needing node / npm.
Starts faster.
Lockdown specific application versions, and easily rollback.
Faster deployments.

Deploy a standalone node.js server from WebStorm express project

Total rookie question, however in my hours searching have not found a proper solution:
I have made a Node.js/express server using WebStorm IDE, tested it and run it successfully, however now that it is complete, I would like to be able to run it manually as a standalone project.
I have tried just running the www js file, which does start the server, however some functionality is lost, such as being unable to find and run a python script (not found).
My question is how do I fully transfer all the functionality incorporated in the WebStorm project so that server can be run outside of the IDE?
ADD: Currently only python scripts in the /bin directory will be found (server terminal run location)

Interactively debugging a Node.js application on Heroku?

My Node.js application runs correctly locally but it has errors once deployed to Heroku.
I cannot use node-inspector to debug as it requires three ports, and Heroku allows only one port.
https://discussion.heroku.com/t/how-to-debug-node-on-heroku-using-something-like-node-inspector/477/6
I cant use the debugger built into Node.js because I need a CLI to issue debugging commands.
http://nodejs.org/api/debugger.html#debugger_debugger
What is the best strategy for interactively debugging a Node.js application on Heroku?
Found One-Off Dynos, which allow:
Running a console (also known as a REPL shell) to run arbitrary code or inspect the app’s models against the live database. (e.g. rails console, irb, or node)
https://devcenter.heroku.com/articles/one-off-dynos#types-of-one-off-dynos
I didn't have time to test, but this should let me run the built in node debugger.

Categories

Resources