daemontools

October 9, 2024 by Roberto Puzzanghera 34 comments

daemontools is a collection of tools for managing UNIX services. It monitors qmail services and saves error messages to one or more logs.

Changelog

  • Oct 9, 2024
    - added -ltr to conf-ld to restore compatibility with systems with glibc prior to v. 2.17 like RHEL6/CentOS6, where the librt.so library is not linked
  • Oct 4, 2024
    - version 0.78.1: added package/compile which was missing again! (tx Bai Borko)
  • Sep 6, 2024
    - fixed a .gitignore issue which was preventing the package/compile script upload (thanks Ivelin Topalov)
  • Jul 29, 2024 (version 0.78)
    - multilog prints a readable datetime if used with "d" flag, it prints timestamps if used in the usual way with the "t" flag (80f2133)
    - fixed several compilation warnings and/or breaks on gcc-14.1
  • Dec 9, 2023
    -moved my patched daemontools to github and named 0.77 the new version
    -clear service moved to qmail/supervise/clear

multilog program with human readable datetime

The multilog program has been modified to work both with timestamps and human readable datetimes (commit).

The action t inserts an @, a precise timestamp, and a space in front of each line, using the same format as tai64n.

Example:

multilog t '-*' '+* fatal: *' ./main

prints the line

@400000003b4a39c23294b13c fatal: out of memory

The action d inserts a human readable datetime in front of each line and a space.

Example:

multilog d '-*' '+* fatal: *' ./main

prints the line

2024-07-29 10:36:08.811661123 fatal: out of memory

Both flags are required to be the first action.

Other patches applied

The daemontools that we are going to install contains the following patches to the original djb daemontools-0.76:

Installation 

First of all, let's create the folder which will host qmail, daemontools and ucspi-tcp:

mkdir /var/qmail

In this guide I will assume that all the source packages have been downloaded into the /usr/local/src folder.

SRC=/usr/local/src
DAEMONTOOLS_VER=0.78.2
cd $SRC
wget https://github.com/sagredo-dev/daemontools/archive/refs/tags/v${DAEMONTOOLS_VER}.tar.gz
tar xzf v${DAEMONTOOLS_VER}.tar.gz

Install daemontools:

cd /var/qmail
mkdir admin
chmod 1755 admin
cd admin
cp -rp ${SRC}/daemontools-${DAEMONTOOLS_VER}/admin/daemontools-${DAEMONTOOLS_VER} .
cd daemontools-${DAEMONTOOLS_VER}
chown -R root:root .
package/install

So we have daemontools in /var/qmail/admin/daemontools

Add the "clear" service, so that you can easily clear the readproctitle service errors line:

mkdir -p /var/qmail/supervise/clear
touch /var/qmail/supervise/clear/down

cat > /var/qmail/supervise/clear/run << __EOF__
#!/bin/sh
yes '' | head -4000 | tr '\n' .
__EOF__

chmod +x /var/qmail/supervise/clear/run

Running daemontools at boot time

The command /command/svcscanboot will be added in your /etc/inittab. It will be sufficient to run qmail at boot time.

On systemd based OS the above command has to be added to rc.local in order to be executed at boot time, supposing that rc.local is executed at boot time, or you can choose to create a specific daemontools.service as follows:

cat > /etc/systemd/system/daemontools.service << __EOF__
[Unit]
Description=Daemontools service supervision
ConditionPathExists=/command/svscanboot

[Service]
ExecStart=/command/svscanboot
Restart=always

[Install]
WantedBy=multi-user.target
__EOF__

systemctl enable daemontools.service
systemctl start  daemontools.service

Comments

Error while installing daemontools

HI Roberto, 

I am facing issue while package/install of daemontools on RHEL6/CentOS6 and below is the error message 

./compile timestamp.c
./load multilog deepsleep.o timestamp.o match.o time.a unix.a byte.a
timestamp.o: In function `readable_datetime':
timestamp.c:(.text+0xc): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [multilog] Error 1

Regards

Shailendra

Reply |

Error while installing daemontools

Hi Shailendra,

that clock_gettime function is in the time.h file of the glibc library. Probably it is not linked to the timestamp.c program. Which glibc version do you have? (ldd --version)

Can you modify the src/conf-cc file like this

-gcc -O2
+gcc -lrt -O2

and run package/install again?

Anyway you can solve installing the original daemontools-0.76 patched with the errno.patch, but please let me know if the above test works for centos 6.10

Reply |

Error while installing daemontools

Hi Roberto, 

Tried the hack that you suggested but still getting the same error

./compile timestamp.c
./load multilog deepsleep.o timestamp.o match.o time.a unix.a byte.a
timestamp.o: In function `readable_datetime':
timestamp.c:(.text+0xc): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [multilog] Error 1

Kindly find the output of ldd --version

ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

As suggested by you I tried with daemontools 0.76 and I get the following error

./load envdir unix.a byte.a
/usr/bin/ld: errno: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference in envdir.o
/lib64/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [envdir] Error 1

Regards

Shailendra

Reply |

Error while installing daemontools

Sorry for the wrong suggestion I gave before. Use conf-cc and conf-ld like these

conf-cc with no modifications, so

gcc -O2

add -lrt to conf-ld

gcc -s -lrt

I don't know what's going on for version 0.76

Reply |

Error while installing daemontools

Hi Roberto, 

As per your suggesstion modifying the conf-ld with gcc -s -lrt did the trick and I was able to successfully install daemontools 0.78.1 on RHEL6/Centos6.

Thanks for your help

Regards

Shailedra

Reply |

daemontools-0.78

Hello Roberto

Is package/compile script missing from daemontools-0.78 source package?

BTW thanks for all the great work you and others are doing to keep qmail alive.

Reply |

daemontools-0.78

Unfortunately it is missing. I'm out of home now. I'll correct the problem tomorrow. 

In the meantime you can replace that script with one of a previous version

Reply |

daemontools-0.78

Many thanks Roberto and my heartfelt appreciation for the incredible work your are doing.

Reply |

daemontools-0.78

I've rebuilt the 0.78 package with the package/compile script. 

Thanks for the advice!

Reply |

daemontools-0.78

Hi Roberto,

package/compile script still missing in daemontools-0.78 source?

Reply |

daemontools-0.78

Tx Bai, I've created 0.78.1 with that file added

Reply |

correction

cd daemontools-​${DAEMONTOOLS_VER}

this line also has same 3 hidden chars 9see in hex)

Reply |

correction

Thank you. I retyped those string

Reply |

correction

cp -rp ${SRC}/daemontools-${DAEMONTOOLS_VER}/admin/daemontools-​${DAEMONTOOLS_VER} .

this line somehow has 3 hidden bytes (copy it and look in hex) which makes it wrong

Reply |

suggestion to insert install of build-essentials etc on this page.

is it an idea to put the following already here instead of on page installing and configuring vpopmail?:

apt install build-essential autoconf automake libmariadb-dev libmariadb-dev-compat

Reply |

suggestion to insert install of build-essentials etc on this page.

I created a page with the preinstallation tasks, where this and other preliminary tasks are covered. Fill free to post other hints 

Reply |

suggestion to insert install of build-essentials etc on this page.

ok, inserted

Reply |

make: not found

Hi everybody .

i had a problem need your help :

- when i run a command line :

# package/install 

i see : 

Linking ./src/* into ./compile...
Compiling everything in ./compile...
package/compile: 20: exec: make: not found . 

help me , pls .

thanks.

Reply |

make: not found

I think that you should install autotools. Please refer to your distribution's documentation for the purpose

Reply |

attribute eXecute to "run" file

Hello,

I´m doing a procedure to install qmail to CentOS 8 (systemd)

run file gets 644 attribute, should we change to 744 ?

Thanks for your work !

Marco Varanda

Reply |

attribute eXecute to

yes

Reply |

Supervise not running on debian

If you receive error: Error supervise not running
It's because daemontools/svscanboot is not starting from sysvinit inittab.

To start from systemd:

cat > /lib/systemd/system/daemontools.service << __EOF__
[Unit]
Description=Daemontools service supervision

[Service]
ExecStart=/command/svscanboot /etc/service/
Restart=always

[Install]
WantedBy=multi-user.target
__EOF__

systemctl enable daemontools.service
systemctl status daemontools

Reply |

Broken link

qmail.org  is offline, change:

wget http://www.qmail.org/netqmail-1.06.tar.gz

to

wget https://notes.sagredo.eu/files/qmail/tar/netqmail-1.06.tar.gz

Reply |

patch of multilog file size limit

Hi,

This is the little multilog patch I would like to share.

By default multilog only support max 16MB log file, for my email server, 16MB only can save 5 hours log, so I made this little patch, and change multilog file limit to 100MB, here how to apply:

cd /usr/local/src
wget https://www.phpini.com/files/multilog_filesize_limit.patch
cd /var/qmail/admin/daemontools
patch -p1 < /usr/local/src/multilog_filesize_limit.patch
package/install

and then update log/run file/s, now can assign file size to s104857600 (100MB).

Reply |

patch of multilog file size limit

thank you, Sam.. I'll add it asap

Reply |

patch of multilog file size limit

I have recently installed qmail from all the great information here (thanks for this).  But after reviewing my log files they are all 16M and rotate out after the 10th one (current log and then 9 of the renamed @.....#.s files).  So I did check the multilog.c file from the patch just to confirm and everything looks good there.  But it is still cutting the logs out at 16M instead of 100M.  How do I go about figuring out where to change that value and maybe even increase the number of logs it keeps?

Reply |

patch of multilog file size limit

in the log run file you have something like this

  exec /usr/local/bin/setuidgid $LOGUSER /usr/local/bin/multilog t n5 s16777215 $LOGDIR \

where n5 is the number of log files and s16777215 is the maximum size in bytes. Look here for more info http://cr.yp.to/daemontools/multilog.html

Reply |

clear service

the creation of clear service is non understandeable and not well described

cat > clear/run < 

syntax error near unexpected token `newline'

what must do run to clear ?

no link creation for service clear

Reply |

clear service

thank you, corrected

Reply |

But how do you set the PATH so daemontools can run properly?

I tried installing daemontools exactly as outlined above.  But qmailctl start fails because it can't find svc, svok, etc.  I researched on the web, and it appears that the issue is with daemontools not being found in the PATH.  I've tried updating the path in /etc/profile, and in /etc/inittab (when launching svscan).  Although ps -ef | grep svscan demonstrates that svscan is running, qmailctl can't seem to find scripts in the /command folder.

(Per your suggestion, I'm trying to do this install on Slackware  (version 13.37).)

I also tried running ./rts > rts.out (as mentioned in Dave Sill's book, "Life With Qmail") but it bombs on every line--again complaining 'command not found' one line after the next.

What am I doing wrong?

Thanks in advance for your response.

-Dave Martin

Reply |

Hi Dave, first of all thanks

Hi Dave, first of all thanks a lot for your support.

You should have this PATH inside the /command/svscanboot script:

PATH=/command:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin

qmail should start by means of a line inside /etc/inittab

SV:123456:respawn:/command/svscanboot

so, you may want to check that svscanboot was actually launched on boot, or try to run it manually. I prefer to have it in my rc.local

fyi, I have tested everything on a slackware64 13.37

cheers :)

Roberto

Reply |

Daemantools with systemd

if your linux using systemd

remove SV:123456:repawn:/command/svscanboot from /etc/inittab

create a file at /lib/systemd/system/daemontools.service
edit as

[Unit]
Description=DJB daemontools
After=syslog.target network.target

[Service]
ExecStart=/command/svscanboot
Restart=always

[Install]
WantedBy=multi-user.target

copy links

ln -s /lib/systemd/system/daemontools.service /etc/systemd/system/multi-user.target.wants

reboot ur system

Reply |

I confirmed the settings you gave, but still not working

qmailctl start continues to return errors on line 17: svok: command not found 

However, ps -ef | grep svscan returns the following:

root 1886 1 0 Mar10 ? 00:00:00 /bin/sh /command/svscanboot
root 1948 1886 0 Mar10 ? 00:00:02 svscan /service
root 9379 6093 0 01:12 pts/0 00:00:00 grep svscan

Could there be a permissions issue with the qmail user accounts?  Does the qmail group need to be granted permission to in order to run the daemontool utilities?

Reply |

It's seems like the

It's seems like the daemontools' installation has failed... can you post please:

ls -l /command/
ps axfuww

anyway feel free to contact me in private using the contact button above

Reply |

Recent comments
See also...
Recent posts

RSS feeds