Nodejs as Windows Service can't read files on network drive - node.js

I have developped a little app in NodeJs which read and write some files. These files are stored on a shared folder of my local network. Everything was working until I tried to start NodeJs as Windows Service through NSSM (a little .exe that allows you to transform a .bat to a Windows Service).
In fact, fs.readFile doesn't work anymore so i can't use it, and i don't see where does the problem come from.
In addition, fs.existsSync("\\\\10.200.10.1\\reporting\\") returns false, but fs.existsAsync("\\\\10.200.10.1\\reporting\\") returns true.
I also tried some other functions like fs.access and it doesn't work either.
I would be grateful if someone could tell me how i can make this work. I don't really care about NSSM, my only goal is to make my Node App works as Windows Service, so if an other tool can resolve my issue, let's tell me.
I don't know if it's the same problem, but I have an other thing which doesn't work in service mode : Execute VBS from Nodejs in background mode (Tasks Scheduler or Windows Service)

Related

How does Galaxy Meteor hosting for windows work?

I have a node.js application I have adopted from a more senior developer. I want to deploy it, and I know it will work because he already deployed it several times. I am reading these instructions:
https://galaxy-guide.meteor.com/deploy-quickstart.html
I use windows, as did he.
How does deployment work?
Take these instructions:
Windows If you are using Windows, the commands to deploy are slightly
different. You need to set the environment variable first, then run
the deployment command second (the syntax is the same as everything
you’d put for meteor deploy).
In the case of US East, the commands would be:
$ SET DEPLOY_HOSTNAME=galaxy.meteor.com
$ meteor deploy [hostname]
--settings path-to-settings.json
Am I just supposed to go to the source directory on my laptop and run these commands? What then happens? Is the source uploaded to their server from my laptop and then their magic takes care of the rest?
What about when I want to make a change to the code? Do I just do the same thing, poiting to an existing container and, again, they do the magic?
Am I just supposed to go to the source directory on my laptop and run these commands? What then happens? Is the source uploaded to their server from my laptop and then their magic takes care of the rest?
It is not magic. You basically go to your dev root and enter these commands. Under the hood it builds your app for production (including minification and prod flags for optimization) and once complete opens a connection to the aws infrastructure and pushes the build bundle.
See: https://github.com/meteor/meteor/blob/devel/tools/meteor-services/deploy.js
On the server there will be some install and post install scripts that set up all the environment for you and, if there are no errrors in the process, start your app.
These scripts have if course some automation, depending on your account settings and the commands you have entered.
What about when I want to make a change to the code? Do I just do the same thing, poiting to an existing container and, again, they do the magic?
You will have to rebuild (using the given deploy command) again but Galaxy will take care of the rest.

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

Problems running large command line program (Inkscape) in Azure Function app or App Service

I wasn't sure whether to ask this in an Inkscape specific forum or here in Azure. I tagged both.
My goal is to run a windows build of Inkscape in a cloud function preferably or in an App Service to open up different vector files and send them back to the user as a plain SVG.
I've downloaded the binary archive (https://inkscape.org/en/release/0.92.2/windows/32-bit/) and extracted it in Kudu on both a paid App Service and in a Function App.
When I run inkview.com it seems to be working. It outputs info to cmd
But when I run inkscape.com it just stays open for a couple of seconds and quits. (Just outputs a blank line and exits) I've tried -V and -? and many other commands (also using the -Z without GUI command).
Does anybody have an idea of what's going on here? Is Azure perhaps missing some dependencies that Inkscape needs to run? Any ideas on how to troubleshoot?
Thanks in advance.
Azure Functions, like WebApps and Mobile Apps, run in an App Service. The App Service runs in a secure environment called a sandbox which imposes certain limitation. Amongst them, is the use of GDI+.
With Inkspace being a graphics program, I can only imagine that it is making use of GDI+, so it would be blocked.
You can see the list of limitation https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks
In order to be able to run inkspace in Azure, you need to host in something other than App Service, such as a VM, Cloud Service, Service Fabric, Containers... etc.

How to use firebird embedded on Linux with IBPP without running a service?

We're about to integrate a firebird database in our software via IBPP. Accordingly to the firebird documantation this should be possible.
We already managed to use the firebird database via IBPP while the service was running. But, we want avoid to run a service. On windows we already accomplished to do this - but on the linux side there are two main differences:
Installation
On windows it is not neccessary to make an installation. On Linux it seems to be, as the docs say:
Finally, you can't just ship libfbembed.so with your application and use it to connect to local databases. Under Linux, you always need a properly installed server, be it Classic or Super.
Is this true? I found the firebird documentation beeing outdated sometimes. If this is still valid, how to deal with this installtion? Can we just run it on the customer's pc. I looked at the shell script. It starts a service. For me it seems running this service is needed during installation process. Anyway, this would be no problem if the service is running only for the installtion and is never needed afterwards - but I'm not sure about this.
IBPP
On windows you just load the DLL via loadlibrary: We put the fbembed.dll, icuuc30.dll and icudt30.dll on any_dirctory, changed the passage in IBPP where the embedded dll is called to loadlibary("any_directory\fbembed.dll") and added any_directory to PATH variable. Everything works now. (Aside: By doing this it is possible to call the database via a DLL we created using IBPP. This DLL can be used by every EXE we give to the customer withour caring about the path the EXE is places in).
But on Linux I didn't found the code where this is done. On this HOWTO it seems a special directory structure is needed. Is this really neccessary? Is it possible to place the .so-files on any_directory and run the application from another_dirctory? Is it neccessary to add loadlibary to Linux section in IBPP? (BTW: My problem is I can't really test things because Linux integration is doing someone else for me).

How to execute a setup from an application to update it?

I'am currently writing an application that has to search on a web site if an update exists for this application. If it is the case the application download a setup file (created with inosetup) and then execute it.
My application is written in C++. And I do not arrive to do this process. I'am trying to call the setup using system(). If the command is system("mysetup") I cannot obtain what I want because the setup cannot replace the exe (currently running). So, I have tried to use system("cmd /C mysetup"), system("cmd/C start /min mysetup"), system ("cmd /C start /min /separate mysetup") without success. In these cases, the fact to stop the application also stop the setup. So I suppose that the setup is considered as a child process.
I have seen in some posts that it might be possible to use execcl(). But this function is in unistd.h. And this library is a little bit to specific for my needs (I need to be able to run on virtualized windows).
So do you have a way to do what I want?
Thanks for your help
OK,
A colleague to me gave me the solution. As we are using QT a QProcess::startDetached does exactly what I want.

Resources