node.js - Node js start and stop windows services -
i have nodejs app communicates third party application installed windows service. nodejs application requires service running, if circumstances may not.
im trying search method check if windows service running , if not start it. after many days searching have found many results running nodejs application windows service not 1 providing ability start/stop installed windows services.
is possible? have found tools psexec make nodejs run such script preferable if nodejs perform task natively.
any information end useful , find hard believe others haven't been in situation have needed also.
stephen
in windows, command line can type:
# start service net start <servicename> # stop service net stop <servicename> # can pause , continue
so, simple answer - use child-process start service on startup of server. this:
var child = require('child_process').exec('net start <service>', function (error, stdout, stderr) { if (error !== null) { console.log('exec error: ' + error); } // validate stdout / stderr see if service running // perhaps. });
edit: found nodejs module called "windows-service". seems promising attempting do. of functionality implemented in c++ attempts query windows service manager.
Comments
Post a Comment