How to use the node-windows.Service function in node-windows

To help you get started, we’ve selected a few node-windows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kennethrisa / discord-rustserverstatus / install / uninstallSVC.js View on Github external
// for windows - uninstall windows service
var Service = require('node-windows').Service;
 
// Create a new service object
var svc = new Service({
  name:'discord-rustserverstatus',
  script: require('path').join(__dirname,'app.js')
});
 
// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall',function(){
  console.log('Uninstall complete.');
  console.log('The service exists: ',svc.exists);
});
 
// Uninstall the service.
svc.uninstall();
github ioBroker / ioBroker.js-controller / build / windows / uninstall.js View on Github external
var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'ioBroker',
  script: require('path').join(__dirname, 'controller.js')
});

// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall',function(){
  console.log('Uninstall complete.');
  console.log('The service exists: ',svc.exists);
});

// Uninstall the service.
svc.uninstall();
github sematext / logagent-js / bin / logagent-windows.js View on Github external
grow: 0.5
    })
    svc.on('error', console.log)
    // Listen for the "install" event, which indicates the
    // process is available as a service.
    svc.on('install', function () {
      console.log('Logagent service installed')
      svc.start()
    })
    svc.on('start', function () {
      console.log('Logagent service started')
    })
    svc.install()
  } else if (process.argv[2] === '-uninstall') {
    let Service = require('node-windows').Service
    let svc = new Service({
      name: 'Logagent',
      description: 'Sematext Logagent',
      script: process.mainModule.filename
    })
    svc.on('uninstall', function () {
      console.log('Service Logagent removed.')
    })
    svc.uninstall()
  } else {
    if (process.argv.join(',').indexOf('--config') === -1) {
      // use default config
      process.argv.push('--config')
      process.argv.push(process.env.LOGAGENT_CONFIG || process.env.ProgramData + '\\Sematext\\logagent.conf')
    }
    var la = new (require('./logagent.js'))()
    if (!la) {
github sematext / logagent-js / bin / logagent-windows.js View on Github external
#!/usr/bin/env node
'use strict'
try {
  if (process.argv[2] === '-install') {
    var laCmd = process.mainModule.filename
    // var exec = require('child_process').execSync
    // exec('powershell -command "Set-ItemProperty -Path \'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment\' -Name LOGAGENT_CONFIG –Value \'' + process.argv[3] +'\'',{stdio: [0,1,2]})
    console.log(laCmd)
    let Service = require('node-windows').Service
    let svc = new Service({
      name: 'Logagent',
      description: 'Sematext Logagent',
      script: laCmd,
      wait: 2,
      grow: 0.5
    })
    svc.on('error', console.log)
    // Listen for the "install" event, which indicates the
    // process is available as a service.
    svc.on('install', function () {
      console.log('Logagent service installed')
      svc.start()
    })
    svc.on('start', function () {
      console.log('Logagent service started')
    })
github ioBroker / ioBroker.js-controller / build / windows / install.js View on Github external
var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'ioBroker',
  description: 'ioBroker Controller service.',
  script: require('path').join(__dirname, 'controller.js'),
  env:{
    name: "NODE_ENV",
    value: "production"
  }
});

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

// Just in case this file is run twice.
github kennethrisa / discord-rustserverstatus / install / installSVC.js View on Github external
// for windows
// Install as a service
// https://stackoverflow.com/questions/20445599/auto-start-node-js-server-on-boot?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

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

// Create a new service object
var svc = new Service({
  name:'discord-rustserverstatus',
  description: 'Updates activity status on discord bot and displays how many players are connect to your rust server from rest api',
  script: require('path').join(__dirname,'app.js')
});

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

svc.install();
github jon-hall / pm2-windows-service / src / install.js View on Github external
yield common.admin_warning();

    let setup_response = yield no_setup ? Promise.resolve({
        perform_setup: false
    }) : inquirer.prompt([{
        type: 'confirm',
        name: 'perform_setup',
        message: 'Perform environment setup (recommended)?',
        default: true
    }]);

    if(setup_response.perform_setup) {
        yield setup();
    }

    let service = new Service({
        name: name || 'PM2',
        script: path.join(__dirname, 'service.js')
    });

    // Let this throw if we can't remove previous daemon
    try {
        yield common.remove_previous_daemon(service);
    } catch(ex) {
        throw new Error('Previous daemon still in use, please stop or uninstall existing service before reinstalling.');
    }

    // NOTE: We don't do (name = name || 'PM2') above so we don't end up
    // writing out a sid_file for default name
    yield* save_sid_file(name);

    yield* kill_existing_pm2_daemon();
github nitzzzu / alexa-local-skills / winservice.js View on Github external
const Service = require('node-windows').Service;

let svc = new Service({
    name: 'AlexaSkills',
    description: 'Alexa Skills',
    script: require('path').join(__dirname, 'server.js'),
    maxRetries: 3
});

svc.on('install', function() {
    console.log('Install complete. Starting...');
    svc.start();
    console.log('Service started');
});

svc.on('uninstall', function() {
    console.log('Uninstall complete.');
    console.log('The service exists: ', svc.exists);
});
github stuartZhang / node-web-proxy / lib / buildWinService.js View on Github external
async build(listenPort, systemProxyPort, gwlFilePath, prFilePath){
    if (!await exists(SERVER_LOG_DIR)) {
      await mkdir(SERVER_LOG_DIR);
    }
    let isReinstall = false;
    const svc = new Service({
      name: SERVICE_NAME,
      description: 'Web Proxy for HTTP(s) through the system proxy.',
      script: SCRIPT_PATH,
      abortOnError: false,
      logpath: SERVER_LOG_DIR,
      env: [{
        name: 'DEBUG',
        value: '*'
      }, {
        name: 'PORT',
        value: listenPort
      }, {
        name: 'SYSTEM_PROXY_PORT',
        value: systemProxyPort
      }, {
        name: 'GUEST_WHITELIST',
github hoodiehq-archive / local-tld / lib / servicemanager.js View on Github external
var os = require("os");
var path = require("path");
var fs = require("fs");
var exec = require("child_process").exec;
var service = {};

var config_file = require("./config").file;
var service_file = path.join(path.dirname(module.filename),"service.js");

switch (os.platform()) {
  case "win32":
    var win = require("node-windows");
    var svc = new win.Service({
      name: "Local-tld",
      description: "Routes local.dev domains",
      script: service_file,
      env: {
        name: "LOCAL_TLD_CONF",
        value: config_file
      }
    });
    service = {
      install: function(done){
        svc.on("install",function(){
          if (done) done();
        });
        svc.install();
      },
      remove: function(done){

node-windows

Support for Windows services, event logging, UAC, and several helper methods for interacting with the OS.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis