coreybutler / node-windows

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

Service immediately stops after being started #227

Closed kirillVv closed 5 years ago

kirillVv commented 5 years ago

Trying to create a small panel with NW.js to manage the service for my Webserver. The service is being installed, but when i try to start it the Event log shows that it stops immediately. When i create the service the normal way with js script and command prompt the service functions normaly and doesn't stop.

Err.log shows this message:

FATAL ERROR: v8::Context::SetAlignedPointerInEmbedderData() Pointer is not aligned 1: 00007FF89CE2F7CF node::CallbackScope::~CallbackScope+91391 2: 00007FF89CEC1406 node::FatalException+182 3: 00007FF89CEC1CA0 node::FatalException+2384 4: 00007FF8A2B96F29 v8::Context::SetAlignedPointerInEmbedderData+121 5: 00007FF89CEB9ACE node::Buffer::New+104318 6: 00007FF89CEBA2B0 node::Buffer::New+106336 7: 00007FF8A2C48753 v8::internal::operator<<+145939 8: 00007FF8A2C47BDD v8::internal::operator<<+143005 9: 00007FF8A2C47271 v8::internal::operator<<+140593 10: 00007FF8A2C46EF1 v8::internal::operator<<+139697 11: 00007FF8A346DCF2 v8::internal::NativesCollection<2>::GetScriptsSource+625010

I create the service with node "vm" module like that:

`

 const code =`
    (function (require) {

    const Service = require("node-windows").Service;

    var svc = new Service(`+ config + `);

    svc.install();

})`;

vm.runInThisContext(code)(require);`

where config is: var config = { name: "InventarServer", description: "Inventarsystem NodeJS", script: "C:\\path\\to\\server.js", nodeOptions: [ "--harmony", "--max_old_space_size=4096" ] };

Using latest NW.js build: v0.35.0

coreybutler commented 5 years ago

I assume you've seen https://github.com/coreybutler/node-windows/wiki, and it sounds like you're building a separate app to manage the process... which is possible. The issue is almost certainly within the VM, which runs in a very different context and almost certainly doesn't have the required permissions.

I'd suggest not running it in a v context. It may just work, but you'll at least see a different error. The error you're receiving looks like it's coming from NW.js.

Closing as this doesn't appear to be a node-windows issue. This would be a better question for StackOverflow.