Re: How to re-"use Module" if the Module has changed?



>>>>> "PL" == Paul Lalli <mritty@xxxxxxxxx> writes:

PL> andrew.fabbro@xxxxxxxxx wrote:
>> I have a script which runs as a daemon. Periodically, the user wants
>> to change some of the config variables for it. Right now, those config
>> variables are stored in a perl module, and the daemon does a 'use
>> Module' to import them at run-time.
>>
>> What I'd like to do is have the module reread its config if it gets a
>> HUP signal. But how can I say "go and 'use Module' again"? It appears
>> that if you 'use Module' more than once, subsequent calls are ignored.

PL> Completely untested, based soley upon the docs in
PL> perldoc -f require

PL> $SIG{HUP} = sub {
PL> delete $INC{'Module.pm'};
PL> require Module;
Module-> import();

that import is useless as it is generally meant to modify the symbol
table at compile time and this is late in run time.

and you could just slurp in the module (if you know where it is) and
eval it. also i would isolate the data into its own module as there is
no reason (unless the code will change too) to reload the code each
time. and those variables have to be package globals. this leads to
other issues.

i would not even go in this direction and instead would use a config
(not perl code) file (many on cpan) and just reload that into your data
(preferably a single hash for isolation).

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.



Relevant Pages

  • Re: setup mail server
    ... I should warn you that I've had some issues with the Dovecot POP/IMAP ... It's a nice daemon: very easy and simple to configure because ... leave messages on the server, causing them to download ALL of their old ... > dont remmember the standard config that comes with Fedora, ...
    (Fedora)
  • Re: Adding additional postfix server to init daemon
    ... Does anyone have an idea as to add additional postfix servers? ... You'll see the config dir for the second instance ... $DAEMON start 2>&1 | ... echo "." ...
    (Debian-User)
  • Re: Adding additional postfix server to init daemon
    ... Does anyone have an idea as to add additional postfix servers? ... You'll see the config dir for the second instance ... $DAEMON start 2>&1 | ... echo "." ...
    (Debian-User)
  • Re: Check the DB-handle status.
    ... I want to check the status of my db, in my daemon on a regular base. ... Also I want to reread the DB config. ...
    (perl.beginners)
  • Re: I cant get named to start
    ... so I won't attempt to debug your config ... would start with the -u switch as "daemon". ... and maybe also: chown -R myuser /var/run/named ... Email replies to: ...
    (comp.os.linux.networking)