I have a lot of small Perl daemons with a common configuration.
Currently, I use this to load the settings:
In myconfig.pm:
package MyConfig;
use base 'Exporter';
BEGIN {
our @EXPORT = qw( $DB_DSN $DB_USER $DB_PWD );
}
our @EXPORT;
use vars @EXPORT;
$DB_DSN = "DBI:mysql:...";
$DB_USER = 'asdad';
...
And in daemon.pl:
use MyConfig;
This works just fine. But now I have the new requirement to reload the configuration when the USR1
signal is received. I know about
$SIG{"USR1"} = sub { ... }
but what next? use MyConfig
again? Looks mad.
My scripts have to run on many different platforms and different perl versions from 5.8 to modern, so I'm trying to avoid CPAN modules.
Please point me to good solution about this task.