gpt4 book ai didi

node.js - 无法使用node-windows启动Node JS服务

转载 作者:太空宇宙 更新时间:2023-11-04 01:18:06 25 4
gpt4 key购买 nike

我已经安装了node-windows模块并使用下面的脚本创建了Windows服务。它已经创建了一个 Windows 服务,但是它没有启动并抛出以下错误

创建服务的脚本

 var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
name:'Node HtmlToPDF',
description: 'Node JS Application which converts Html String to PDF',
script: 'C:\\Users\\Dell\\eclipse-workspace\\HtmlToPDF\app.js',
wait: 2,
grow: .5
});


// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});

svc.install();

下面是当我尝试启动但它从未启动时它抛出的消息。是否还需要进行其他配置?我尝试过使用 SC STARTNET START 启动,但没有成功

C:\WINDOWS\system32>sc start nodehtmltopdf.exe

SERVICE_NAME: nodehtmltopdf.exe
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 17888
FLAGS :

C:\WINDOWS\system32>net start nodehtmltopdf.exe
The Node HtmlToPDF service is starting.
The Node HtmlToPDF service was started successfully.

最佳答案

这是我的错误,更新如下路径后,它起作用了。最后错过了一个斜杠。

script: 'C:\\Users\\Dell\\eclipse-workspace\\HtmlToPDF\\app.js'

关于node.js - 无法使用node-windows启动Node JS服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60249278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com