Deploy Node JS REST APi Mongo DB on Windows - node.js

I'm new to node js. In the last months, i developed a REST API using node js, Express and Mongo DB for my customer.
I would like to deploy the WEB API on Linux, but now my customer asks me to deploy the solution into a Production Environment with Windows Server 2008 / 2012 R2.
Which is the best way to deploy this solution on Windows Server?
There is some best guide to see?
Thanks

PM2 on Windows:
Personally I am using pm2 on my linux machines. Pm2 is a process manager for node apps, which makes deployment and maintainance of your node applications a lot easier. You can also use pm2 on windows, see: https://github.com/Unitech/pm2
You need to make sure pm2 start upon restarts / server crashes and therefore you want to setup a service. You could take a look at: https://github.com/jon-hall/pm2-windows-service which may be a help for that purpose.
Docker:
If you are just struggling because it's windows and you are still looking for your "common deploy methods" you could still setup a docker container with your favourite environment. However if you don't have experience with it, it is probably a bad idea to test it first in a customer project.

Related

Publish Windows service in Microsoft store with NodeJS or Electron

I'm looking for a the golden advice.
I've created an app that listens to websockets over a certain port and then sends commands to a native module (wrapped by NodeJS). now all this is done in NodeJS app. and packed in exe file (with two extra files for the native module ".dll and .napi")
now I want two things:
Run this app as a windows service in the background.
Package it in an installer that should stop the service (if exists), install the new update, then re-run the service. this app will be published in Microsoft store as appx.
I'm new to all of this so I feel lost while trying to know which is the best approach with my little knowledge.
I'm a bit confused between NodeJS and ElectronJS, some people say electron is not the best choice for services, but electron-builder is a great tool for packaging.
Conclusion: I want to publish my app to Microsoft store (already bought a developer account), and to run it as a service (no GUI). and the code is written in JS (node or electron)
Thanks in advance

How to host a React App on Standalone Server

I have a stand alone server that will only be connected to a lan without outside internet access. I am new to hosting so I am lost as to what to use and how to do it.
I have run my react app using npm start. But how do I configure node to start up a react app when the stand alone server starts?
Is there some other windows based host that is easier to configure to run a React app?
I would probably use a Linux server distribution to achieve this. Quite easy actually but not sure how to do that on a Windows machine, unfortunately. You can simply Google for "How To Setup A Web Server And Host Website" I am sure there are a lot of guides and tutorials

Deploying React & Node.JS as a service Linux Ubuntu 14

Have a Node.Js API and a React app semi finished. Working on deploying to get the development cycle churning. Currently using npm start for viewing the react server during development. Same for the Node API. When deployed to AWS EC2 I am building in the most basic fashion, npm build pushing to a 'release' folder.
Once the deploy folder is up, I can go into it and run serve -s release
This gets me up and running. I can do the same for api server.
To get the apps running as a service, for the api, I can see how I can build a systemd process and run that with no issue.
For the react app, is there an easy way to run that server as a system... I'm new to this stack, so I might be confused. I have read in some places that once you've built your react app that you need to serve it out via apache or nginx? (e.g. in development it hosts itself, in production, you need to serve it) Is that sort of the general idea - build with local hosting, deploy with a production webhost?
Help appreciated. This is my last major issue before I can get Jenkins running a nice pipeline for deployment. Thanks!
Since you are already running a NodeJs server, It would be a good idea to host your ReactJs App in the NodeJs App itself.
You can pipline in the Jenkins to Build the ReactJs App first and the move it to static serving folder in the server and then you just need to deploy the NodeJs app in which ever environment that you want.

how to deploy nodejs rest api with express framework on production server windows

I have created a node.js rest api created using express framework for routing. I have used tutorial
Now I want to deploy that rest api on actual production server. How to achieve that thing.
I have gone through below links.
Deploy node js application with express framework on production mode --- Only for linux. I need for windows.
Deploying NodeJs Express Rest API to Windows 10 IoT -- a little bit similar problem but no solution
https://stackoverflow.com/a/38652869/2810015 -- this said to run npm start on production server after copying all of the files on server. But this is not working fine either.
Any help will be highly useful.
You use pm2?
Usually I use it to start the application. It works for both windows and linux. He leaves the service initated, and in case something happens that knocks the service up again.
You install it on the server, and instead of using it
node server.js
You use the command below
pm2 server.js start
Link: http://pm2.keymetrics.io/docs/advanced/pm2-module-system/

Some questions on node.js development environment and deployment strategy

I'm new to node and reading some books about it. Now I think it's time to do some dev stuff with it. I'm planning to implement a little project which I want to deploy in the cloud (AWS, Heroku, ...).
What I still haven't figured out are following points (I have a MacBook Pro with OS X 10.7):
which dev environment should I use? I thought about Aptana Studio (no node support as far as I've seen) and transferring the files via ssh to a local VirtualBox CentOS 6.3 machine which has node.js and some modules installed on it
is there any good deployment strategy for hosting my app in the cloud? For example, if I'm developing with Aptana Studio, I don't think there is a plugin which let's you deploy your code on some virtual server in the AWS or Heroku cloud, isn't it?
Thanks in advance!
I don't use an IDE per-se. I get by with just Sublime Text for my editor.
The deployment process will depend on where you host your site. I am not sure about Heroku, but with Nodejitsu it's just as simple as running "jitsu deploy" from the terminal and that's it.
If you host the site on your own on a Linux box (i.e. without Heroku or Nodejitsu) you need to account for how to make sure the site restarts after the machine reboots, or after a crash. I wrote about this on my blog. It's doable but somewhat of a chore: http://hectorcorrea.com/blog/running-a-node-js-web-site-in-production-a-beginners-guide
You can and should develop and run your application locally on your mac. Dealing with 2 machines, 2 OSes, and constant file transfers is a nuisance in development and offers no benefit. It also cripples nice things like fsevents for watching files and good text editor integration.
If you are into the whole IDE thing, perhaps consider https://c9.io/
There are several cloud Platform as a Service companies you could consider
http://nodejitsu.com/
https://devcenter.heroku.com/articles/nodejs
https://www.dotcloud.com/
http://www.cloudfoundry.com/
http://www.windowsazure.com/en-us/develop/nodejs/tutorials/getting-started/
Here's some blog posts reviewing some of these PaaS offerings
http://mrdanadams.com/2012/node-js-paas-hosting-services/
http://ocdevel.com/blog/nodejs-paas-comparison
In terms of deployment, most of these PaaS companies are going to integrate with npm and github, so deployment is going to take no more than a handful of commands at most.
Thanks for your help!
After doing a lot of research on the topics you've posted, I just wanted to let you know what my setup for developing node applications now looks like:
Sublime Text 2 Text-Editor with Package Manager and following plugins: git, nodejs, SublimeLinter (BTW: are there some other "essential" plugins you can not live without?)
iTerm 2 Terminal for all console work (execute node-inspector, ssh to server etc.)
node.js, npm and additional modules which I want to use for my app
Running everything local on my MacBook Pro. As far as I could test this solution, it seems that it runs very smoothly but most notably: FAST :-)
Regarding node deployment, I take Heroku and nodejitsu into account due to low costs, few administration efforts and features like auto-scaling etc. The only drawback of Heroku is the missing websocket support, which I intend to use natively in my app.
Best regards!

Resources