I have created a web application using React framework. I am able to Run it in localhost using npm start command.
I have a server in AWS ubuntu 14.04. I have uploaded all code there and run the application using npm command. It is working well. But if i close the terminal then it has been stopped. I know we need to run that instance or service. But how can we do it forever without any UI of ubuntu?
Did you link the public directory's file(HTMl/PHP file) to your dedicated host server?
If not, Look to do how to setup it with AWS in local you can do it with virtual hosting. I'm sure in AWS there'll be any same way to do.
You can use a library called forever which will keep the process running in the background.
https://github.com/foreverjs/forever
Related
What's the point of having Node.js and Vue.js installed on my host and then also getting a Node/Vue image for Docker? Every Vue.js tutorial says to install Node and Vue to the host first and then get the Docker image, is this not redundant?
Examples:
https://morioh.com/p/3021edac7ef1
https://jonathanmh.com/deploying-a-vue-js-single-page-app-including-router-with-docker/
https://mherman.org/blog/dockerizing-a-vue-app/
I'm using a Windows 10 host and was trying to avoid installing Node and Vue to Windows if possible, unless there are particular advantages to doing so, which hopefully someone can enumerate. Otherwise, maybe someone can confirm that it's redundant to also install Node/Vue on the host and state why it's silly and redundant.
Like you say, it is redundant but easier. A container is a running instance of an image, an image that was created (probably) using a Dockerfile with the instructions, so how would you go about doing everything from the container?
Would you add the creation of the app to the Dockerfile or would you connect to the container using bash and run the commands from there? If you connect with bash you'll lost everything once you remove the container. Once your app is created inside your container how would you get it out? I mean you need to write your app's code. You could store you data using docker volumes but that gets complicated depending were you are running Docker. For example on Mac a virtual machine is created for Docker, so to find that data you'll need to connect to the virtual machine...
It is just easier to do all of that from your local machine and use docker to host your app.
I am using node-windows in nodejs to run my nodejs script as a windows service.
now let's suppose that my helloworld.js code is a simple command which creates a folder on desktop. how do I execute this code ??
because my service app starts successfully but it does not do anything at all. it creates no directories on desktop.
please help..
what error am I doing?
I have a nodejs application that should start when I turn on the machine (I'm using Linux Ubuntu 16.04 so I put it in the rc.local). my application uses the raw-socket package.
Since my application cannot run as root, in the rc.local, I set:
sudo -u myuser node myapp.js &
when my application calls "new raw-socket", I got an error:
Operation not permitted.
I tried different methods such as "setcap" but they don't work for me.
Furthermore, if i try to run my app after the operating system is loaded, the app works perfectly without any problem....
should I have to add something in the rc.local....did I miss something?
node-raw-socket needs root access to create its raw sockets.
You will have to run
sudo node myapp.js
I have a nodejs app which should start running when windows starts. As I'm new to node and have never done anything similar I don't know how to do it. I have been reading some articles from several webs that use AdvancedInstaller or other software but don't know if there are any ways to do it without using other software. Anyone can help?
You need to use pm2
There are other packages aimed at making pm2 a windows service:
pm2-windows-startup
pm2-windows-service
It seems like you need to create *.sh script and put in the Startup folder
maybe this can help you
or just google sh script startup nodejs windows
I am currently building a web app using express.js and mongodb. My problem is I do not know how to run mongodb itself in production. Because in the development, I used mongod command, but it need the terminal to be open so mongodb will run. How can I do this in the real server? In my express app, I just use pm2 to run it.
Since you are not an expert on managing this, I would suggest you to use some mongodb-as-a-service, so that they manage that for you and you just simply access it. for example: https://mongolab.com/
Or you can use https://www.mongodb.com/cloud so that you can just lunch a few commands in your server and mongodb+backup will be installed in your server and you can update, or make clusters simply using their interface.
Or if you want to install it in your server, guessing you are using linux, and probably an ubuntu based distro you can run mongod like #aiobe suggested: sudo service mongod start