[fpc-pascal] Daemon question
Henry Vermaak
henry.vermaak at gmail.com
Thu May 14 11:07:38 CEST 2009
2009/5/13 Koenraad Lelong <fpascal at brouwerij.homelinux.net>:
> Hi,
> I wrote a daemon monitoring my solar powerstation. It works fine but I
> want to extend it.
> At the moment I log everything to file, and I put some data into rrdtool.
> I would like to be able to ask the daemon some information, but I don't
> know how to do this.
> I made some signals : sigterm to terminate gracefully, sighup to
> restart, sigusr0 to get the uptime and sigusr1 to get some device-info.
> Except, sigusr0 and sigusr1 use writeln's to output the data which I
> never see when I ask for them (kill -10 <processid>). Where do these
> writeln's write to ? Sigterm and sighup do work fine, so I think my
> handler is OK.
> How can I get that info ? It should be software-independent, because I
> would like to use php to get that information.
> I thought of writing the info to a file, but that info is updated every
> 15 seconds. I think it's not good to write a new file every time.
> Now I'm writing this, I could write to a file after receiving a signal,
> and then reading this with php.
> Thinking about it, does php support sending signals ? Back to the books.
i think the most elegant and scalable solution is to write a
client/controller program that communicates with the server. this
client can control the server, set options, get information/status via
sockets, or some form of ipc. php can then call this client with the
required options and use the output. a lot of unix daemons use this
approach, see udevadm (for udev) and smbcontrol (for samba), for
example.
if this is too much trouble, your daemon can just append data to log
files every x seconds and php can read these files. you will have to
implement some log rotation scheme, though, or the log files will take
over your system.
henry
More information about the fpc-pascal
mailing list