coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.82k stars 356 forks source link

command line arguments #100

Open tallesl opened 9 years ago

tallesl commented 9 years ago

It's possible to setup a node script as a service passing specific command line arguments to it?

scaret commented 9 years ago

+1

vicneanschi commented 8 years ago

+1

bladerunner2020 commented 8 years ago

I miss this feature as well.

bennomatic commented 8 years ago

+1

I'd love this as a feature!

NogsMPLS commented 8 years ago

would absolutely love this.

If @coreybutler could point us in the right direction, maybe one of us can see about making a PR for this feature?

coreybutler commented 8 years ago

For what I think people are generally wanting, the starting point is in the wrapper.js. This file essentially behaves like a command line app, and the lines referenced above are where the child process is launched. I believe this could be modified to support additional user-provided arguments.

One point I want to stress is cross-OS API consistency. While node-windows/mac/linux are separate repos, the overarching goal is to provide a consistent API, regardless of OS. The wrapper files of each project are very similar, and this particular use case is one I would want to see in all 3 wrappers.

If anyone decides to take this on, let me know. For one, I sincerely appreciate any assistance, and I'm happy to answer questions via Gitter or in this issue. It's certainly something I wouldn't have a problem merging so long as the cross-OS API consistency remains intact.

bennomatic commented 8 years ago

Thanks for the update. I'll look into wrapper.js, but additionally, I've found something else that seems to work: the Non-Sucking Service Manager (nssm.cc). The name is terrible, but the system works nicely. Basically, it allows you to configure whatever you want (like node, with the appropriate command line parameters) specifying whatever start directory you want (e.g. your project's directory). It then sets up a Windows service to call up an instance of itself with the parameters which tell it how you want your service instantiated.

Fast, easy setup. I wish they'd change the name, since I had to cringe when writing up that section of the deployment guide, although I have to say the client has not complained... But name aside, give it a try!

NogsMPLS commented 8 years ago

Almost got this working locally. I can pass arguments, only problem is that everything wants to look in system32 directory for all other files.

coreybutler commented 8 years ago

@bennomatic - I intentionally moved away from nssm during the early days of this project. It has some problems when it comes to logging, so I am extremely unlikely to swap out winsw.exe at this time. Of course, nothing is stopping you from keeping a fork up using nssm!

MarkAurit commented 8 years ago

2-3 years ago I was researching ways to run a node app as a Windows service. Nssm rated lowest on my list which included node-Windows and iis-node.

Regards, Mark Aurit

On Mar 24, 2016, at 4:40 PM, Corey Butler notifications@github.com wrote:

@bennomatic - I intentionally moved away from nssm during the early days of this project. It has some problems when it comes to logging, so I am extremely unlikely to swap out winsw.exe at this time. Of course, nothing is stopping you from keeping a fork up using nssm!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

NogsMPLS commented 8 years ago

got command line arguments working! Should have PR in today

carnesen commented 8 years ago

I was trying to figure out how to pass command-line arguments to the node executable and landed here. If you're in my boat, the solution is to add a "flags" property to the service definition object whose value is a string with space separated arguments. The default value for this "flags" property is "--harmony".

scpeterson commented 7 years ago

What is the status of this issue? I see that there is an outstanding pull request, but it seems to have stalled.

coreybutler commented 7 years ago

I just haven't had a chance to go through the merge conflicts in the PR. If someone sorts out the merge conflicts, I'd be happy to merge it.

scpeterson commented 7 years ago

It looks like the PR was done prior to some major changes, so I'd feel more comfortable if someone more familiar with the code dealt with the conflicts.

StingyJack commented 7 years ago

I was able to just create another wrapper script that had the parameters I needed and have node-windows call it instead.

the file looked something like this...

var cp = require('child_process');
cp.exec('harp server c:\\mywebpath\\ --port 1234');