Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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();
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();
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) {
#!/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')
})
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.
// 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();
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();
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);
});
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',
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){