This cookbook installs the Non-Sucking Service Manager (http://nssm.cc), and exposes resources to install
and remove
Windows services.
- Chef 12.7+
- Windows
Add recipe[nssm]
to run list.
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
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
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.
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.
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. Optionalparameters
- Hash of key value pairs where key represents associated registry entry. Optionalstart
- Start service after installing. Default - truenssm_binary
- Path to nssm binary. Default -node['nssm']['install_location']\nssm.exe
- Ask specific questions on Stack Overflow.
- Report bugs and discuss potential features in Github issues.
Please refer to CONTRIBUTING.
MIT - see the accompanying LICENSE file for details.