Saturday, December 2, 2017

Windows Services and latest developments

Among the recent changes to our Kitto2 repo is restored support for running a Kitto application as a Windows Service, which was disabled when porting the code from Kitto's previous life and has been just reimplemented and enhanced.

Running HelloKitto as a Windows Service

If HelloKitto.exe is not run by an administrative account, it will default to running as an application. Otherwise, it will run as a service and interpret the -install and -uninstall command line switches (you can also use slashes instead of dashes) to register and unregister the service in the Service Manager. From then on, you just start and stop the service from the Control Panel (by default, it's an auto-start service but you can change this and other parameters through the new Service section in the Config.yaml file.

Note

You can run HelloKitto as an application even when running it from an administrative account, by passing the -a command line switch.

The same applies to all Kitto applications, of course. No changes needed to application code or project files.

Kitto.Start.pas

A Kitto application can run as an application or service (and soon also command line application and Linux daemon) off the same compiled executable with the same project file code. All the intricacies are encapsulated in the Kitto.Start.pas unit; you just need to call Kitto.Start as the sole code in your project file and the rest will be taken care of.

Going forward

As we add more deployment options to Kitto (mainly ISAPI and Apache module), a separate project file will be needed for each one, as Delphi project files for programs and libraries are structurally different; we will aim to keep the required code in the project file to a minimum anyway.

A huge internal refactoring has just taken place to allow new deployment options to be implemented soon in an easier way. Specifically, the TKWebServer class was split into an HTTP server class that handles requests and responses and an engine class (which is a route) than handles sessions and controls the TKWebApplication class which is the heart of a Kitto application (and itself a route). The route subsystem has been refactored as well to allow route composition through the TKWebRouteList class.

No comments:

Post a Comment