wkhtmltopdf as node module fails when run as windows service - node.js

I am running a node app that uses the wkhtmltopdf module (https://www.npmjs.com/package/wkhtmltopdf) and node routing to return a pdf of a page when the user navigates to a /pdf path. Everything works fine when the app is run on in the servers console, but when the app runs as a Windows service, the pdf call fails. I get the browser crash screen with the message that the site refused to connect. The rest of the site works fine, just the path to return PDFs fails, and I can't glean anything from the logs. Is this a known issue with wkhtmltopdf?

OS: Fedora
I had the issue with my node server program and wkhtmltopdf module in it, not generating pdf when run as a service. Turns out that a user for the service was set as nobody and so was usergroup. We removed that entry and reran the service it works.
I am guessing this could be the issue with Windows as well.
Please let me know if it did not work, did work or you already solved the problem with another approach.

Related

deploying nodejs and mongoDB to azure

I have a nodejs/express application and an atlas mongoDB set up. I can get the data from the database to my app if it is running on local host. When I try and deploy the app as a web app through Azure, it does not work; I click the button to get/display the data but nothing happens. What is causing this issue and how do I fix it?
I figured out what was wrong. My repository did not include a web.config file at all. Having never worked with web applications or Node before, I did not know this was needed. Once I added the file and put the proper path in, the code began working as intended. I can update this post with actual code if someone wants it.

How do i fix shiny deployment issue in browser when running locally?

I am running into issues deploying my shiny application. In R Studio, it states that the application has been deployed successfully, as per the image below.
Successful deployment message
However, I get "An error has occurred. The application failed to start. Contact the author for more information" when opening the application in the browser (chrome and safari).
Error in browser version of application
It also states the application is running on my shiny account.
enter image description here
Does anyone have any recommendations to what problem is occurring here that prevents the shiny app from being run in a browser? The app runs locally without any issues too.
I have all packages installed and up to date and the file directory is correct. I am not running on an SSL network either.
Thanks in advance.

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

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.

net::ERR_CONNECTION_REFUSED when moving app from local machine to remote server

Had a look around at some other threads and there doesn't seem to be someone with this exact problem.
The problem is that I have made a webapp that works fine when hosting it locally. On the app there is a button that causes a request to be sent to my server and it performs as expected on localhost:3000 but when I host it remotely on a linux box purchased from digital ocean the site loads but the when the button is pressed I see
net::ERR_CONNECTION_REFUSED
in the console.
I'm not sure how useful it would be to post code so I will leave that out unless requested. I'm hoping this is due to some server configuration issue?
Further info:
This is a node application on a server running ubuntu. To run the application I use and keep it running I use PM2.
Thanks in advance.

Resources