Skip to content

criteo-cookbooks/nssm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3de3892 · Nov 19, 2021
Nov 18, 2021
Jul 28, 2017
Jul 24, 2018
Jul 26, 2017
Nov 19, 2021
Nov 19, 2021
Nov 18, 2021
Aug 9, 2015
Nov 18, 2021
Jul 24, 2018
Jul 7, 2017
Nov 18, 2021
Aug 8, 2015
Nov 18, 2021
May 8, 2017
Aug 2, 2017
Jul 24, 2018
Nov 19, 2021

Repository files navigation

NSSM Cookbook

Cookbook Version Build Status

This cookbook installs the Non-Sucking Service Manager (http://nssm.cc), and exposes resources to install and remove Windows services.

Requirements

  • Chef 12.7+

Platform

  • Windows

Usage

Add recipe[nssm] to run list.

Quick Start

To install a Windows service:

nssm 'service name' do
  program 'C:\Windows\System32\java.exe'
  args '-jar C:/path/to/my-executable.jar'
  action :install
end

To remove a Windows service:

nssm 'service name' do
  action :remove
end

Using Parameters

A parameter is a hash key representing the same name as the registry entry which controls the associated functionality. So, for example, the following sets the Startup directory, I/O redirection, and File rotation for a service:

nssm 'service name' do
  program 'C:\Windows\System32\java.exe'
  args '-jar C:/path/to/my-executable.jar'
  parameters(
    AppDirectory: 'C:/path/to',
    AppStdout: 'C:/path/to/log/service.log',
    AppStderr: 'C:/path/to/log/error.log',
    AppRotateFiles: 1
  )
  action %i[install start]
end

Attributes

  • node['nssm']['src'] - This can either be a URI or a local path to nssm zip.
  • node['nssm']['sha256'] - SHA-256 checksum of the file. Chef will not download it if the local file matches the checksum.

Resource/Provider

Actions

  • install - Install a Windows service, and update it accordingly. (Note: it will NOT automatically restart the service, make sure to notify the according service to restart)
  • install_if_missing - Install a Windows service, but do not update it if present (old behaviour)
  • remove - Remove Windows service.
  • start - Start the Windows service.
  • stop - Stop the Windows service.

Attribute Parameters

  • servicename - Name attribute. The name of the Windows service.
  • program - The program to be run as a service.
  • args - String of arguments for the program. Optional
  • parameters - Hash of key value pairs where key represents associated registry entry. Optional
  • start - Start service after installing. Default - true
  • nssm_binary - Path to nssm binary. Default - node['nssm']['install_location']\nssm.exe

Getting Help

Contributing

Please refer to CONTRIBUTING.

License

MIT - see the accompanying LICENSE file for details.