[Lazarus] Environment monitoring software on Linux?

Bo Berglund bo.berglund at gmail.com
Thu Sep 26 23:16:03 CEST 2019


On Thu, 26 Sep 2019 13:00:59 -0400, wkitty42--- via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>On 9/26/19 11:12 AM, Bo Berglund via lazarus wrote:
>> Is cron the best way or is there some similar function like the
>> Windows services one can easily create?
>
>generally speaking, cron is the equivalent of the winwhatever scheduler...
>
>> If so is there some sample
>> code in FreePascal for implementing a service?
>
>why? when you deploy your project, include the needed steps to add the polling 
>schedule to the existing cron on the linux system...
>
>either that or just build a scheduler into (or wrap one around) your project 
>that polls at regular intervals...
>

OK, using cron to start the scheduler program is probably the best way
on Linux. Once a minute with a quick check for queued tasks and then
exit.

I have one problem though, every time the scheduler starts (via cron)
it will check if there is a task ready to start at that time.
If there is it will engage with the hardware and set it in motion,
wait for the measurement to end and then retrieve the data and finish.

If the measure process takes longer than until the next cron
invocation due to some extra delays in that particular process, then I
don't want the new instance of the scheduler to start another task.
The reason is that the hardware is occupied.

Instead I want the new instance to just exit or else go into some wait
loop until the first instance quits.
I don't like the use of lock files in order to control this since if
the process crashes it will leave behind the lock file and the system
blocks.

So is there some way to let an fpc process determine if there is
another instance of itself running?
In Windows I used something called Mutex, which was managed by Windows
and so could not be left behind...


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list