Currently, I met a problem when building a web server with Node Express. The problem is how to update some of the service configurations without restarting the service.
For example, the CDN site URL root or user upload file storage folder could be changed from time to time. Now, I put these service configuration into the object, which is required, when express server fires.
I know the nodemon could be used to monitor the file changes, and restarts itself.
Is there a better way to hot update these configuration variables without any outage?
BTW: in production deployment, it uses pm2, and the express server would run in multiple processes.
I have a web app developed with a NodeJS + Express + GraphQL + MongoDB back-end and a ReactJS + Apollo front-end. I would like to deploy this application locally. Is that even possible?
I have come across dozens of "how to deploy to Heroku," "how to deploy to Digital Ocean", "how to deploy to Github", etc. But none that explains how to deploy locally.
Right now, I run: nodemon server for the back-end, and npm start for the front-end. I see the application running on http://localhost:3000/ (I use cors to connect the front end with the server running on port 3001).
I would like to just go to http://localhost:3000/ and see the app without having to execute the commands npm start and nodemon server. Is this possible? If so, how do I do that?
To my knowledge, our local server is not a WAMP server (our OS is Windows though). The IT department told me that it is a
[...] plain, regular old server. The address is localhost running on
port 3000. You can open up another port on 3001 if you need it. Just
drop your stuff on the C: drive and you should be good to go. I've
never heard of Node or React so I can't help if you have questions.
Any ideas? Many thanks in advance for your help!
UPDATE
There seems to be a bit of confusion surrounding what I am looking for. I am trying to deploy this locally.
Let's say, on your local computer (your laptop at home) you go to localhost:3000 on your favorite browser. Unless you are serving something to localhost in that moment nothing is going to show up, it will say "refused to connect" or something. What I want is to be able to open any machine on the network whenever I go to localhost:3000 and my react site appears and functions...does that make more sense?
I don't want this is development mode. I want a build of this project on localhost...I'm starting to think this isn't possible.
As i understood, you want to deploy it on a local server, not locally on your developing device.
I thought about doing that...but I'm not so sure IT will be okay with it always running... :(
How can you use a server if its not running? Just like WAMP (which runs apache), or whatever you got rolling there, it must be running. So, just make it a background process like slawomir suggested.
PS I dont think you understand node server properly though.
Read this to understand why node server needs reloading. After that you need to understand that no hot reload tool is perfect, and you gonna need to restart your server from time to time.
PPS I dont know what this means
[...] plain, regular old server. The address is localhost running on port 3000.
if there is a server running on 3000, youll need to change port for your server to smth else (most common is 9000)
To solve the problem you can create a startup script, which executes npm start and nodemon server. Then make sure to keep it hidden, so that your server will be always running. Keep in mind though, that any errors thrown will stop your server and unless you configure it, the server won't reload by itself.
I would try following:
build your app with the production environment variables set
get all files from dist folder and deploy them in your server
now access your app using localhost/
Maybe what you are looking for is something like ngrok which creates a socks tunnel to your localhost, effectivelly deploying from localhost, as I understand it, allowing you to access your localhost through a url like ldiuhv093.ngrok.io, or even a custom subdomain if you pay for a subscription fee.
If I have this wrong, someone please tell me!
To solve the problem first of need to create a batch file with .bat or .cmd extension and under that file add the following 2 command
nodemon server
npm start
Then follows the following steps to add it as a startup script for windows OS.
Create a shortcut to the batch file.
Once the shortcut has been created, right-click the file and select
Cut.
Press the Start button and type Run and press enter.
In the Run window, type shell:startup to open the Startup folder.
Once the Startup folder has been opened, click the Home tab at the
top of the folder and select Paste to paste the shortcut into the
folder.
Above steps are for example to create a batch file and add it as a startup script for Windows 8 and 10 users.
For better clarity or reference follows the following link.reference-link
There's no option to reload the server while keeping it running. You could, technically, have your 'main' file monitor another file for changes. This would be the file where you actually keep your sever program. Then, on changes, you discard your current logic and start executing that. That said, doing it that way would be very fragile and a very round-about way to do it. It also wouldn't fix your front-end for which you'd need a similar solution.
Instead, you could hook into your favorite editor's save event, and run those two console commands, so that every time you save, the server is automatically brought up. (Make sure to also clean up existing servers)
Run on Save for VSCode
save-commands for Atom
I know this post has been two years. But, I think the solution to your second desired outcome is to use concurrency. https://www.npmjs.com/package/concurrently.
This will allow you to do one NPM START to start two all three processes.
and to your first question, I think the solution is to add Electron to your app so you can package it to an executable application. When you start the app, your express server will start running in the background.
Most people probably don't understand why there is a need for this. Running on local server (computer) allows access to local file system and can even run SQL queries inside the proxy which would require IT involvement if hosted on outside server.
From what I have understand, that you want to deploy your app on local server that means you want to deploy it on the network that you are connected to.
Check ip from the command prompt
To deploy it locally,
Run: HOST=ip npm run start
It will get deploy on your local server. And everyone connected to the server can access the url
If this worked for you, kindly upvote
You need to do npm start There may be other ways of starting it but, all will result in the same. You can read this article on Freecodecamp on deploying on DigitalOcean. You can manipulate it to your localhost. Shouldn't be too different.FCC Tut on Deploying
So, im running phpstorm with nodejs plugin that runs a server on local machine.
But i have to manually restart the server each time i change something. It would be very nice if it could automatically restart it, kind of like automatic deployment or just working with php.
Is there any way i could configure that?
Yes - you can try using Live Edit for this (you need to install the corresponding plugin from a repository). See http://blog.jetbrains.com/webstorm/2014/08/live-edit-updates-in-webstorm-9/
i'm using JBoss 5.1.0.GA on a linux machine and i'm deploying an ear for an EJB project, while looking at the server logs, i undeploy the old ear and it undeploys successfully then i put my new ear in the deploy directory and also the logs show that it is deployed successfully but when running the project, the new changes don't take effect and the old ear content gets executed instead. please advise!
i had this problem with 5.1 EJB3 projects on a windows machine a couple of times. Something very fishy going on.
have you tried everything?
i.e. undeploy, stop the service, restart the machine if possible, start the service, re-deploy
i remember in my case it stuck until the machine was restarted. never actually found the problem though.
After shutting down the server, just delete all of the temporary folders that get generated when JBoss starts. Those folders are (if you use default folder):
/server/default/data
/server/default/log
/server/default/tmp
/server/default/work
After deleting them, just restart JBoss and all your new changes should be there.
I've added a handful of new builds to a long standing CruiseControl.Net setup. Everything has been smooth up until this point. Now, any changes I make to the header.xsl file do not display on the build results dashboard page. This behavior only appeared after the weekend, and I'm not seeing any errors from CC.Net. Any clue as to what might be causing this? I've already attempted restarting both CC.Net and IIS.
Current CC.Net version info: 1.5.7256.1
When changing something related to dashboard configuration (or XSL files) you should
restart web server
restart ccnet
From my experience
using ccnet as service + apache + mod_asp, I need to restart only ccnet service.
using ccnet as service + IIS, I need to restart IIS and sometimes to restart the PC !
Did you change the correct header.xsl?
For the web dashboard you want to change webdashboard\xsl\header.xsl, and may need to reload the dashboard config before you see the change.
The server\xsl\header.xsl file is used when using the EmailPublisher.