Deploying a Node App that uses Node-Watcher - node.js

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.

Related

Publishing NextJS to IIS

I'm trying to publish a NextJS website on IIS, I've already installed URL Rewrite and IIS Node on the server, I tried following this guide to set up a reverse proxy, but that didn't seem to work, as even though I was running the project on the server, it wasn't redirecting to it.
I then tried hosting with a custom server, this works when running locally, but when run next build, copy the generated .next folder, package.json, web.config, and server.js onto the server where IIS is being hosted, running node server.js doesn't seem to work, as it simply stops after:
info - SWC minify release candidate enabled. https://nextjs.link/swcmin
No other question or blog I see seems to cover hosting on a different computer than the one used to develop, so I'm not clear on whether or not I'm simply supposed to copy the entire source code to the production server, and run next start there, that would not seem ideal.

Are mariadb-install-db and mariadb-secure-installation necessary for each project?

I want to use MariaDB/MySQL local server with PHP on my computer for developing a web app.
I use Manjaro Linux, already installed mysql/mariadb and necessary other packages (via pacman).
Every time before I connect to my local mysql/mariadb database server, do I have to do mariadb-install-db and/or mariadb-secure-installation on the project folder?
Otherwise it seems that I cannot connect my local db service via PHP (mysqli or pdo).

ReactJS: How to deploy on local server

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

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