Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change daemon directory #269

Open
hosseinpro opened this issue Aug 13, 2020 · 6 comments
Open

Change daemon directory #269

hosseinpro opened this issue Aug 13, 2020 · 6 comments

Comments

@hosseinpro
Copy link

I put my source files in /src similar to many other projects and since my index.js in under /src the output daemon folder will be created as /src/daemon. I need to specify the output daemon folder in node-windows config like daemonDir. If you add this option it's very good.

Meanwhile, I solved my problem as follows:

I changed node_modules\node-windows\lib\daemon.js file at line 258 from:

_directory: {
      enumerable: false,
      writable: true,
      configurable: false,
      value: config.script !== null ? path.dirname(config.script) : null
    },

to

_directory: {
      enumerable: false,
      writable: true,
      configurable: false,
      value: config.daemonDir !== null ? path.dirname(config.daemonDir) : null
    },

And specify daemonDir at config:

var svc = new Service({
  name: "My Server",
  description: "My Server",
  script: "src/index.js",
  daemonDir: "./",
});
@Aoiujz
Copy link

Aoiujz commented Sep 8, 2020

I really need this option too!

@DevRCRun
Copy link

DevRCRun commented Sep 8, 2020

I'll be looking at this today too, as I ideally want the scripts and their daemon directories away from the project

@jhong-mw
Copy link

jhong-mw commented May 3, 2021

This would be very useful!

scheppsr77 added a commit to SummitIT/node-windows that referenced this issue Jul 1, 2021
based on hosseinpro  comments
coreybutler#269
@can-acar
Copy link

I added custom property 'installPath':'./daemon' my repo: https://github.com/can-acar/Node-Windows

@mdodge-ecgrow
Copy link

I wanted to install a second Node service from the same base folder. I followed @hosseinpro 's instructions to create the daemon in an alternate folder. I had this line in my install file: daemonDir: './daemon-process-queue', but for some reason it still installed to the same daemon folder as the other service. Now I have both in there with different names. I was able to start both services under services.msc. Now I am wondering if this will cause any future problems or not?

@korzo
Copy link

korzo commented Mar 18, 2024

While this is fixed, you can replace the _directory property

const service = new Service({
  name: 'My Service',
  script: join(__dirname, '..', 'main.js'),
});

const installDir = join(__dirname, '..', '..');

Object.defineProperty(service, '_directory', {
  enumerable: false,
  writable: true,
  configurable: false,
  value: installDir,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants