Roger Walker wrote:
On Mon, 3 Dec 2007, Niklas Therning wrote:

I'm writing a qpsmtpd plugin for our custom spam filter. The plugin reads a
couple of custom configuration files at startup. The config files may change
at any time and I would like my plugin to pick up those changes automatically.

Now, I've tried to periodically check the timestamp of the files in my plugin
and reload them if necessary but never got that to work. I've posted on this
list before about that problem but got no replies
(http://www.nntp.perl.org/group/perl.qpsmtpd/2007/11/msg7501.html). Now I'm
trying to come up with an alternative solution.

Is there any way I could tell a running qpsmtpd-forkserver instance (version
0.32) to reload its plugins without having to restart the process? I guess it
would work to restart it entirely but it seems to me that it would be better
to just have it reload the plugins so that any running connections don't have
to be killed.

I'd be happy to upgrade to a newer qpsmtpd version if that is required or use
a different daemon instead of forkserver if that would solve my problem.

Regards,
Niklas Therning
www.spamdrain.net

        You can read the config files in one of two locations. At the top
of the plugin, before you define the routines and hooks - this will read
them whenever you restart qpsmtpd. In that case, if you make a change, you
can do "svc -h /services/qpsmtpd/" - assuming that is how you are running
it - it your config files will be reread.

Hmmm, I'm not familiar with svc -h but I guess it sends SIGHUP to the process, right? Does that really work with forkserver? I was under the impression that I would have to stop and start qpsmtpd-forkserver in order for it to reload my plugins. I would like to avoid that since ongoing connections would have to be killed.

        Otherwise, you can read the config files within the subroutines
that you hook to. Each time the subroutine is run, it will read the config
files.

I'd rather not reread these files on every call to my plugin. The files doesn't change very often but there will be a lot of connections all the time.

My previous approach only read the files if they had changed but the updated values in $self didn't stick. I posted about this problem a couple of weeks ago but got no replies. I guess I could try and store the config values as global variables instead of using $self and see if that works better... But the more I think about it telling qpsmtpd to reload all plugins seems like the better solution. It would certainly make my plugin a lot less complex.

Regards,
Niklas Therning
www.spamdrain.net

Reply via email to