Update service configuration without restarting Express server - node.js

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.

Related

Deploy Blazor Server Side app without stopping site

What is the recommend strategy to deploy a Blazor server SPA on a windows server machine with IIS without having a (even very short) downtime?
When I do some changes, I publish the project on local folder but then I have to manually stop the site on the server, else the copy hangs due file access lock.
Thanks
In my opinion, if you want to achieve zero downtime publish the new site, the only way is using two server.
You should use two servers and IIS load balance. You could firstly modify the load balance to transfer all the request to the second server and then publish the application to the first server.
After you tested the first server and make sure the first server is working well. Then you could transfer all the request to first server.
More details about how to use IIS loadbalance, you could refer to this article.
At the end, I created a .bat that before copying to production server rename a App_offline.xxx file in App_offline.htm, copy the files and then do the vice versa renaming.
Some seconds of downtime (with a message "server updating, refresh in few seconds...") much better that manual stop the site and then restart.

Deploying a Node App that uses Node-Watcher

I've just finished developing my Node app that uses node-watch to actively monitor a specific folder on my intranet network and parse CSV data into a database table as soon as someone drops a CSV file in the monitored folder.
I could test it successfully in my machine (I didn't need to install this package globally) and it's working just fine. Now is time to deploy it to the production server on the Intranet and due to information protection standards, this server has no access to the internet.
I've copied my entire app folder including node_modules to the server. The application successfully started and is running but nothing happens (neither errors) when I drop files into the monitored folder. Maybe node-watch is not a pure JS module but I can't run NPM Install on this server as it has no access to internet.
Any Ideas?
Could not find an easy solution to overcome this problem. It was easier working with the server team to open internet access to the service account that is running the node process. Once we do that I executed NPM INSTALL and re-installed all dependencies on the server. It's working now.

deploy single file on node.js production server without restarting server and down time

We are planning to start our new project in node.js but I want to be clear on the deployment side. Previously we have some applications written in asp.net. We deploy our applications as websites so when some page changes we deploy only that page on the web server and we don't need to restart the website or server. This type of deployment where we can deploy a particular page reduces our risk of letting those changes go on the production which we don't want to release as opposed to the mvc where you have to deploy the dll.
So my question is that can we do that kind of deployment on our node.js production site where I can deploy only one changed file lets say 'abc.js' and I don't need to restart the server and the connected users to my site shouldn't experience any issue or disconnection as in the case with .net mvc where user's session is ended.
Sorry if this seems too basic but I need to know.
Thanks

How do I update a live Node.js Heroku App remotely?

I have a Node.js app that is live on Heroku
The Node.js folders/files that I uploaded on Heroku also reside on my computer
Whenever I update my Node.js folders/files on my computer, I want these updates to also be applied to the folders/files that are live on Heroku.
I want to be able to do that without having to stop, update and restart my Heroku app every time.
What I'm describing is basically a setup equivalent to that of the standard ftp connection that we all use whenever we make a local to remote update of static files of some standard website.
The git support that apparently Heroku offers doesn't do that. It requires for the app to be stopped (by running the appropriate commands on the terminal), then I need to make a git push (using the terminal) that updates all of the files (which takes forever) and not just the ones that need to be updated, and then the app needs to be restarted (again using the terminal). This is extremely frustrating for an app that is still in development, requires constant updates and cannot be tested locally (for a number of reasons).
Whenever a Node.js app is tested locally, the app can be started by calling supervisor app.js instead of node app.js.
What this does is it allows for the app to be updated and as soon as that happens (i.e. as soon as I hit "save") supervisor automatically restarts the app locally.
I'm looking for something similar to the above, i.e. linking my local app folder to my remote app folder and starting my remote app (on Heroku) using some supervisor mode so that as soon as my local folder is updated, my remote folder is also changed and the app automatically restarted.
It's extremely frustrating trying to test a Heroku app (that obviously needs constant updates) currently.
Testing it locally and then publishing it on Heroku (for good) will not do because some apps simply cannot be tested on localhost.
Any help would be much appreciated!
The git support that apparently Heroku offers doesn't do that. It
requires for the app to be stopped (by running the appropriate
commands on the terminal), then I need to make a git push (using the
terminal) that updates all of the files (which takes forever) and not
just the ones that need to be updated, and then the app needs to be
restarted (again using the terminal). This is extremely frustrating
for an app that is still in development, requires constant updates and
cannot be tested locally (for a number of reasons).
First, you don't need to stop your app before running git push heroku master. Just push, and the platform will build, and then restart your app with the new code, automatically. Second, git uses a diffing algorithm, so you aren't pushing all of the files - you're in fact just pushing the differences (assuming you're using git correctly). Third, you don't need to do that final, manual restart - the platform has already done this for you on push. Finally, I would advise that if your app is impossible to test locally, you might want to reconsider the architecture of that app. It sounds very un-portable. Perhaps refer to 12factor.net for a good architecture checklist.
Testing it locally and then publishing it on Heroku (for good) will not do because some apps simply cannot be tested on localhost.
What type of app are you building that would be impossible to test outside of a production environment?
In any case, the closest thing I'm aware of to what you're looking for is Dropbox Sync:
https://devcenter.heroku.com/articles/dropbox-sync

cakePHP, what to do next?

I've followed some tutorials about cakePHP and now it's done, the "mvc" is ready.
What should I do next?
Meaning: I was working locally, can I simply upload the complete app online and it is secured as 'they' meant it to be?
I've downloaded the 1.3.6 package from https://github.com/cakephp/cakephp/archives/1.3, and deployed it as is in a folder named as my domain.
Edit:
I have win-xp with wamp.
I created the app by simply unzipping the file to a folder and then renamed it to 'domain_name'.
Then I made the db connection and set the configuration files.
At that point I created the models, views and controllers.
Now the application is working, locally.
My question is: can I simply upload everything to my server, to the html root folder and say that "I am done"?
As long as your app isn't already in production, putting it online can tell you more about how it's working. For instance, you'll learn if there are missing modules or dependencies that must be installed on the live server.
If it's an already live system, you may want to use an online staging server to understand what needs to be modified on the production server in order to have a smooth deployment.
There are three ways that you can deploy your cake app (Development, Production and Advanced), and all of them are secure:
http://book.cakephp.org/view/912/Installation
I would recommended the Production install if you aren't going to run any other apps on this server.

Resources