BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Operations-Friendly Windows Services

| by João Miranda on Oct 07, 2013. Estimated reading time: 1 minute |

DevOps on Windows has for the last few months been running a series on how a developer can create an operations-friendly Windows Service. The series explains how to overcome the most important hurdles from an operations viewpoint: installation of the Windows Service and its start-up phase.

Some of the hurdles are due to common usage of InstallUtil, a non-native Windows tool, to install .Net based Windows Services. The start-up phase requires some care in order to provide clear error messages on the event of a failure and to support long running operations, like loading and caching data from a database.

DevOps on Windows proposes to solve those challenges with a very simple framework on which Windows Services can be built. The framework’s fundamental premise is self-containment: a Windows Service application should know how to install itself, as well as gracefully handle start-up failures. The framework revolves around three classes: BasicServiceInstaller; BasicService; and BasicServiceStarter.

BasicServiceInstaller provides the self-install and self-uninstall functionality, foregoing the application’s need to have its own Installer, a .Net class that provides a foundation to build custom installations. This self-install capability means that the operations team does not need to use any external tools, such as sc or InstallUtil.

BasicService ensures that the start-up phase follows some best practices regarding the interaction with the Service Control Manager. This Windows process manages all the registered Windows Services, including their lifecycle, where it dictates rules that all Windows Services have to follow. BasicService helps in two ways. First, it makes sure that a meaningful error code is returned to the Service Control Manager when the Windows Service cannot start. Second, it helps the developer to code long running start-up operations without having the Service Control Manager forcibly terminating the Windows Service.

Finally, BasiceServiceStarter has the responsibility of determining the mode of operation of the application: install the service; uninstall the service; run as a console; or run as a Windows Service. BasicServiceStarter also ensures that any background thread’s exception messages that might occur on the Windows Service start-up are reported to the Windows event log.

The series runs for seven articles, explaining in detail the reasoning behind this framework. The site’s philosophy is: “Instead of focusing on automation, focus on consistency and simplicity in you software.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and dont miss out on content that matters to you

BT