Run a script after RT loaded

Hi all.

I wrote a module for RT and wanted to invoke of of the functions of that module as soon as possible in the load process. I searched and tried many different things but nothing works… My last try was to have something like this:

package Module;
use strict;
use warnings;

package MGS::RMQ;

(…)

{
MGS::RMQ->StartConsumer();
}

sub StartConsumer {
(…)
}

and several different versions of this. I also tried adding a line like that in the SiteConfig, on httpd-rt.conf, adding a script with that line in the @INC dirs. Nothing seems to work.

Any idea?

Thanks in advance.

Hi all.

I did some advance on this but it’s not working as I expect. Now I have a fork calling the function so I have something like this in my module:

our $pid;
run_b() if not defined $pid;

sub run_b {
$pid = fork;
return if $pid;
MGS::RMQ->StartConsumer();
}

So when this module loads the StartConsumer is called. But unfortunately it seems the module is not loaded only once but every time something is called on it, so now I get many instances of Consumer instead of only one.

What am I doing wrong here? Am I wrong in assuming modules would load only once?

Thanks in adavance.