Adug Melbourne Meeting October 2024

Hi Everyone, The Melbourne ADUG October meeting is on Monday Night, 21st October

This month Grahame Grieve will giving a presentation on
Writing a service application for windows, linux and OSX in FPC - challenges and solutions

Grahame will be on the Nullabor somewhere (SA End) presenting remotely.
The presentation will likely begin somewhere 6:30 to 7:00

When: 6:00pm for a 6:15pm start
Where: At the Melbourne Men’s Shed, and on Zoom.

We are hoping for a good national turnout (Common for Grahame’s presentations).

Zoom link will be up here shortly before the meeting starts.

Note: The AGM is running late this year and will be held in Novembeer.

2 Likes

Geoffrey Smith is inviting you to a scheduled Zoom meeting.
Join Zoom Meeting
Launch Meeting - Zoom
Meeting ID: 871 9172 8932
Passcode: 449517

One tap mobile
+61861193900,87191728932#,*449517# Australia
+61871501149,87191728932#,*449517# Australia

Dial by your location
• +61 8 6119 3900 Australia
• +61 8 7150 1149 Australia
• +61 2 8015 6011 Australia
• +61 3 7018 2005 Australia
• +61 7 3185 3730 Australia
• +1 646 931 3860 US
• +1 669 444 9171 US
• +1 669 900 9128 US (San Jose)
• +1 689 278 1000 US
• +1 719 359 4580 US
• +1 253 205 0468 US
• +1 253 215 8782 US (Tacoma)
• +1 301 715 8592 US (Washington DC)
• +1 305 224 1968 US
• +1 309 205 3325 US
• +1 312 626 6799 US (Chicago)
• +1 346 248 7799 US (Houston)
• +1 360 209 5623 US
• +1 386 347 5053 US
• +1 507 473 4847 US
• +1 564 217 2000 US
• +1 646 558 8656 US (New York)
Meeting ID: 871 9172 8932
Passcode: 449517
Find your local number: Zoom International Dial-in Numbers - Zoom

Here’s my presentation
2024-10 ADUG Services.pptx.zip (34.7 KB)

2 Likes

Grahame Grieve gave an interesting presentation on Services written in
Lazarus for Windows, Linux and MacOS.

Grahame is currently somewhere in SA near the end of the Nullabor,
approaching the final stage of a yearish long trip around Australia.

Some key takeaways.

Grahames Service controller/package, is one he originally built before
delphi got one built in.

  • Delphi Services must not leak memory.
  • Delphi Services need good logging.
    • eg. Why did the service shutdown.
  • The service should log when it starts to a file, and if the startup
    entry does not appear in the file, you need to fix the permissions.
  • Need to test your service under restricted memory conditions.
  • You need to make/find a console emulation, if you want to run a
    console app in MacOSX.
  • Grahame is running his service behind an Nginx proxy, which provides
    protection and other benefits for his service.
  • Service has a telnet entry point, so can watch logs and examine things (eg. Locks)

Also noted from Sue

  • Exceptions all need to be handled (and logged)
  • Using smartinspect has been able to have each thread logging to its
    own log destination/file?

My Note:
If you have the luxury of being able to restart the service
periodically, eg. Sometime at Night. A scheduled task to do that can be good.

There was also a short discussion of the lack of open source CI and
similar functionality available in the Delphi World. Apparently Malcolm
has given a presentation on Jenkins??

Thank you Grahame, and all the attendees.

Sounded like an interesting talk, thanks Grahame, sorry I missed it. Services are interesting beings. Not sure if you mentioned the following but reading over the slides prompted the following thoughts:

  • Creating interactive service apps is possible but problematic. An alternative is to have a service app that runs interactively if you execute another instance while logged in as an interactive user. e.g. we can run our service app exe using a shortcut with the /configure command line option to display the configuration UI (config is saved to a file) and allow execution of the functionality interactively/manually. The non-interactive running service app reads the config file and runs the functionality in the background automatically
  • Re: logging - in addition to logging to file you can also log to the Windows event log. Some IT staff like that but a file is usually better. I like the telnet idea - in a previous company we added a HTTP server within the service app to serve up HTML to display the state and logs from a browser, and some buttons to clear stats counters or the log
  • If you install the service app to run as the default Local System account then the \AppData folder is in an obscure location like C:\Windows\System32\config\systemprofile\AppData\ or C:\Windows\SysWOW64\config\systemprofile\AppData, so you might want to choose a different location to store configuration or write log files
  • Agree strongly with eliminating memory leaks. Also need to catch all exceptions
  • The app should quickly respond to service status changes like start/stop, so you need to limit long running tasks, design loops to be interrupted, threads to be woken etc (e.g. use TEvent instead of Sleep)
  • At system startup the service might be started before some subsystems are ready. e.g. before the network is up so you need to have good retry logic during initialisation
  • Services have a few automatic recovery options such as “start it again” or “run an app” if the service fails
  • To add a description for the service (which appears in the services applet) call Winapi.WinSvc.ChangeServiceConfig2()

Thanks again

1 Like

I mentioned in the chat, just for the sake of cross-reference, that The Silver Coder Tim Coates also spoke about (Windows) services.

It was at the Delphi Dev Days (and also more casually at a Perth meeting)

I also gave a very poor summary of the highlights of 12.2

One thing I had missed was TParrallelArray

You might like to read about it, and see @sglienke (for one) doing some ruthless QA on this new feature. :wink:

Thanks Paul re: TParrallelArray.

That lead to an interesting discussion on various sorting algorithms with benchmark timings. The PDQSort2 that Stefan has working in the Spring4D framework looks impressive.

And the serious bug(s) in TParrallelArray need to be fixed before it can be used in production systems. The discussion was in mid September and I didn’t see any mention of a fix in the recent Delphi 12.2 Patch 1. I wonder if it has been officially reported.

I don’t know if we all appreciate @GrahameDGrieve enough in our community here. :slight_smile:

Here’s a lecture he gave in Melbourne about his job :

and there’s quite a bit online outside of the programming side of FHIR eg :

and a reminder that at the 2023 AGM, Grahame talked about avoiding and diagnosing double frees :

3 Likes