nodejs app as Windows Service, just with an exe - node.js

It is possible to build a nodejs app as a windows service but let the user install this service only by an installer or exe?
I know node-windows, but for this the target system must have nodejs installed.

Related

Azure Pipeline in Ubuntu deployed to Azure App Service in Debian

I am working on a project that needs pdf files created based on a webpage, and went with wkhtmltopdf. The project consists of a python-based web app that runs in an Ubuntu 20 environment. An Azure pipeline is used to deploy the project to a Linux-based Azure app service that uses Python 3. The project runs on a localhost, but deploying it to an Azure app service has been causing issues.
After searching and trial and error, I came up with deploying my project to the Azure pipeline in Ubuntu, and then once the project has been uploaded to the Azure app service, I go into Azure, navigate to the SSH for the app service, and manually install wkhtmltopdf. For some reason, the app service runs on Debian 9, so I cannot create a script in the .yml file for the pipeline. The wkhtmltopdf package that is installed by the pipeline doesn't work with Debian.
I was wondering if there is a way to automatically have the debian app service install wkhtmltopdf. It can be done manually via the SSH in Azure, but with a lot of builds, it would be very time consuming.
Another option is changing the yml file to Debian 9 (which appears not to be supported here), or changing the app service OS to Ubuntu, which I could not find out how to do after hours of searching. It appears that it is automatically Debian 9 based on here
Here is a screenshot of the SSH on Azure
I was able to get wkhtmltopdf to install in the Debian environment by creating a script in the /home directory. I then set the Startup Command in Azure to point to this script.
I don't think Azure runs any auto scripts if you give it a startup command, thus I start the application myself at the end of the script.
Here is the script:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb
apt-get install -y ./wkhtmltox_0.12.6-1.stretch_amd64.deb
rm wkhtmltox_0.12.6-1.stretch_amd64.deb
gunicorn --bind=0.0.0.0 --timeout 600 app:app
Note that I also had to add a pip install python-dotenv above pip install requirements.txt in the .yml file. Not sure why, as dotenv is in the requirements file, but I would get a dependency exception without this line in the yml.

How can Nodejs apps always run as a Windows service?

I have windows Server 2016 cloud hosting. I broadcast my sites on IIS.
I have 2 apps running on Nodejs. I log out of windows after configuring my applications.
My IIS sites continue to run, but my nodejs applications quit when I log out or restart windows.
I have followed the steps below to fix this issue.
I installed the pm2 library. Globally.
npm install --global pm2#latest
I installed the pm2-windows-service library. Globally.
npm i pm2-windows-service -g
I installed the pm2-windows-startup library. Globally.
npm install pm2-windows-startup -g
I uninstall running services to avoid running apps repeatedly.
pm2 kill
If there are any running services, I first uninstall it.
pm2-service-uninstall
I installed the pm2-service-install library. I named it "pm2Service1". I see it started when I enter services.msc.
pm2-service-install -n pm2Service1
I start the startup service for applications to start when Windows opens.
pm2-startup install
I go to the directory where the application is installed and run the application with pm2. (If I don't enter the directory and run it, it gives an error. Can't read the sql / file.sql file.)
c:
cd C:\webSites\myService1
pm2 start app.js
I check the application with list and show, and see if it works.
pm2 list
pm2 show 0
After making sure it works.
I'm recording running applications.
pm2 save --force
When I do these procedures and log off windows, I can access the application from outside.
But when I restart windows the application does not work. I have to repeat the same steps every time it starts up.
When Windows restarts, "pm2Service1" seems to be working. But pm2 list the lists as empty.
I accomplished this on my servers by using NSSM Service. Once you install it, go to NSSM folder and type
nssm install PM2
You can find the entire tutorial here:
https://lakin-mohapatra.medium.com/register-pm2-as-a-service-in-the-windows-server-747f19e2ff2a
Best practice AFAIK is using nssm + "windows batch file" to start your app.js, for more details you can check this link.

I am having issues while deploying react and node application on unix standalone server

I have developed my application on a windows machine and have to deploy this on a standalone UNIX server and while running commands like: npm start, it says that package is not available but I checked and everything is available in the project's npm modules.
Do I need to use docker or how can I achieve that without any container such as docker or kubernete.
Can I try cloning my repo in some other Linux machine and npm install and then use the same folder to deploy on UNIX CentOS running on the server?

How to add npm start as service in windows

I have nodejs project and need to run my node project as windows service. I tried nssm but it is not working. I often use linux . Is there another way to run "npm start" as service in windows without using nssm.

Roostagram node.js IIS

I've been successful in installing node.js and iisnode on my windows server running IIS. I just got back from the jQuery/ROOST conference and I'm playing with the app that they put together. For whatever reason after I've cloned the git repo and installed all packages with npm I'm still not able to get the app running.
I am able to run the app if I run grunt through the command prompt and it starts the test webserver on port 8000, however I would like IIS run the app and handle all requests...
Thanks!
p.s. here is the repo https://github.com/bocoup/roostagram.git

Resources