Skip to content

Install Command Successful but no Service is Installed #380

@terryaney

Description

@terryaney

I have the following 'standard' service.js code (made some 'ugly' single liners to shorten code snippet).

const serviceConfig = packageJson.serviceConfig ?? {};
const host = serviceConfig.host ?? 'localhost';
const port = serviceConfig.port ?? 7801;

// Define the service
const svc = new Service({
	name: 'KAT Camelot Highcharts Export Server',
	description: 'Highcharts Export Server running as a Windows Service',
	script: path.join(__dirname, 'node_modules', 'highcharts-export-server', 'bin', 'cli.js'),
	nodeOptions: [
		'--harmony',
		'--max_old_space_size=4096'
	],
	env: [
		{ name: "NODE_ENV", value: "production" },
		{ name: "PUPPETEER_CACHE_DIR", value: path.join(__dirname, 'node_modules', '.puppeteer-cache') }
	],
	// Add arguments for host and port
	scriptOptions: `--enableServer true --logToConsole false --logLevel 2 --noLogo true --host ${host} --port ${port}`
});

// Listen for the "install" event, which indicates the service is installed
svc.on('install', () => svc.start() );
svc.on('uninstall', () => console.log('Uninstall complete.  The service exists: ', svc.exists));
svc.on('stop', () => console.log('The service has stopped.'));
svc.on('start', () => console.log('The service has started.'));

if (args.uninstall) svc.uninstall();
else if (args.stop) svc.stop();
else if (args.start) svc.start();
else svc.install();

When I install the service it reports success that the service has started, but it is not present in the Services snap-in, but service commands seem to behave as if all is ok.

Command flow

  1. node service.js --install - Reports service is running.
  2. telnet 127.0.0.1 10447 - Reports that it is unable to connect (proving that nothing is listening.
  3. node service.js --stop - Reports that service stopped.
  4. node service.js --start - Reports that service started.
  5. node service.js --uninstall - Reports successful uninstall.
  6. node service.js --uninstall - Run it a second time and reports that the service can not be found, implying that it was found and running in previous command.

Here are screen shots of the flow:

image

image

Things I Tried:

  1. I discovered that the exe was not even created in D:\btr.services\HighchartsExportServer\node_modules\highcharts-export-server\bin\daemon, so I granted full permissions to the user logging in to D:\btr.services\HighchartsExportServer\ and then when I ran --install it correctly created the file, but still same results as above.
  2. I added svc.on('invalidinstallation', () => console.log('The service was unable to install.')); (after already granting full permissions above) and never received this log.
  3. I added svc.on('error', e => console.log('Error:', e.message)); and never recived this log.
  4. Reading the code for daemon.js start it looks like I should get some sort of error if I try starting the service via node service.js --start multiple times but I'm not getting any log there. Only the successful 'start' event.
  5. I tried setting allowServiceLogon: true (not really understanding what it would accomplish) in my service configuration and it didn't have an effect.

Given this information, any ideas of how to continue my debugging efforts of getting this working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions