我正在创建一个 Windows 服务,该服务将一些数据随机添加到数据库中,所以我使用 node-windows 来实现它,当我运行该文件时,它会创建一个可执行文件,当我运行该文件时,我得到“无法从命令启动服务行或调试器。必须首先安装 Windows 服务“我该怎么办??
这是 app.js 文件代码:
var Service = require('node-windows').Service;
var svc = new Service({
name:'finaltest',
description: 'The nodejs.org example web server.',
script: 'testapp.js',
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();
这是 testapp.js 文件代码:
var test = require('./models/test') ;
test.create({test : Math.random()}).then( () => {
console.log('hey') ;
})
setInterval(function(){
test.create({test : Math.random()}).then( () => {
console.log('hey') ;
})
}, 60000);