[fpc-pascal] respawn a daemon in Linux

Michael Schnell mschnell at lumino.de
Tue Jan 14 10:49:47 CET 2014


Hi Linux Experts.

Since years I am running an fpc program as a kind of daemon on a PC 
Linux server.

I simply defined a "respawn" line in /etc/inittab and with any start of 
the server, the program happily automatically runs as a daemon.

Now I migrated the the PC Linux server to an ARM based "QNAP" NAS box, 
which comes with a propriety - but rather normal - Linux distribution. 
Hence I compiled the program with the appropriate ARM fpc and it happily 
runs on this box, as well.

Now the problem is that I can't edit the inittab file on this box, as it 
is in a RAM file system that gets recreated with any start.

But I was able to install an init.d system that allows for running any 
script after booting. Thus I need to find a way to run my program as a 
deamon.

Of course I do know about daemonapp.pp and with that, I suppose I could 
easily have the program daemonize itself. But the program is written in 
a way that it exits whenever some kind of error happens (and this does 
occur, as it accesses multiple sites via TCP/IP. So it relies on the 
"respawn" feature, inittab provides.

I would appreciate any idea on how to create some kind of "respawn" 
algorithm within this program or with a second program - maybe just a 
script. In fact I could use "cron" for this, as happily the system does 
allow me to edit crontab (which here actually is /etc/config/crontab and 
the /etc/config/ is symlinked to a directory residing in a special 
location on a hard disk.

-Michael



More information about the fpc-pascal mailing list