chocolatey/chocolatey — pull request #506 by 030 (2014-07-08 17:23:19+00:00)
Title: (GH-489) Install-ChocolateyService feature

Feature created which is able to create a Windows service by passing packageName, serviceName, createServiceCommand and availablePort (optional).

If the service already exist, this will be stopped and removed before creating the Service to avoid.

If the availablePort parameter is passed, a check will be executed whether the port is available or not. If the port is in LISTENING state, a ChocolateyError will be thrown and the installation exits. If no part parameter is passed, no check will be done.

If the createServiceCommand parameter cannot be executed an error will be thrown and the installer exists.

Some code had to be moved to separate functions to avoid code duplication.

10 tests were run. A bat file containing `ping localhost` was created and run using NSSM to mimic installation and running of a service.