Article View: es.comp.os.linux.programacion
Article #2105Re: ¿Se puede cargar el intérprete de Perl como un servidor?
From: Pascal Bourguignon
Date: Thu, 14 Apr 2005 10:53
Date: Thu, 14 Apr 2005 10:53
95 lines
3648 bytes
3648 bytes
Gorka Olaizola <gorka@helvete.escomposlinux.org> writes:
> Hola,
>
> Tengo un script en Perl y se ejecuta 5 o 6 veces a la vez con par�metros
> diferentes cada 10 o 15 minutos. El script est� en el cron.
> Esto hace que en el momento que se ejecutan la carga suba a 4 o
> 5 durante unos cuantos minutos. Lo suficiente como para que ralentice el
> acceso a otros servicios cada 4 o 5 minutos.
>
> Creo que la carga es porque cada script tiene que cargar los m�dulos que usa
> una y otra vez y aunque est�n en memoria el proceso es lento y pesado.
> �Hay alguna forma de optimizar esto? Quiz�s se pueda exportar s�lo las
> funciones que necesito o poner perl en modo servidor para que se cargue s�lo
> una instancia de todo o alguna optimizaci�n m�s.
>
> Los script son la pasarela RSS / News que hice para la red de servidores de
> Ecolnet.
>
> http://redir.escomposlinux.org/?414bex
Habria que editar un poco el script. Por ejemplo (no lo he comprobado):
----------------------------------------
# MAIN
setlocale(LC_ALL, "");
bindtextdomain($PACKAGE, $LOCALEDIR);
textdomain($PACKAGE);
if (!GetOptions("url=s" => \$url,
"feed=s" => \$feed_name,
"outputcode=s" => \$output_code,
"force" => \$force,
"help" => \&help_sub)) {
&help_sub;
exit 1;
}
die gettext("Usage").": ".$called_name." --url <url> --feed <feed name> [--outputcode <charset>] [--force]\n" unless ($feed_name and $url);
# argument is a URL
$file_name = $DATADIR."/".$feed_name.".rdf";
$ua->agent("Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.6) Gecko/20040614 Firefox/0.8");
#-- A�ADIR AQUI:
while (1) {
#--
$ret = mirror($url, $file_name);
SWITCH: {
if ( $ret == RC_NOT_MODIFIED) {
print STDERR gettext("Data of ").$feed_name.gettext(" not modified since last get");
if ($force) {
print STDERR gettext(" but I will parse the file anyway.\n");
} else {
print STDERR ".\n";
exit 1;
}
}
if ( is_error($ret) ) {
die gettext("Couldn't retrieve page. Error code: ").$ret;
}
# parse the RSS content
# create new instance of XML::RSS::Parser
$rss = XML::RAI->parsefile($file_name);
}
# print the HTML channel
&print_message($rss);
#-- A�ADIR AQUI:
sleep 300
}
#--
----------------------------------------
Pero quizas ser�a mejor probar rss2email que tiene los ventajas que:
- no esta escrito en perl,
- no necesita un proceso por feed,
- lo tengo ejecutando cada minuto y jamas he notado carga ninguna.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
Technical Details
Message-ID:
<87u0m9bpf0.fsf@thalassa.informatimago.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!easynet-monga!easynet.net!easynet-post1!not-for-mailReferences:
<slrnd5s5b3.prl.gorka@conn.helvete.escomposlinux.org>Show Full Headers
Complete Article Headers
X-Google-Thread: f86c8,37b69c33ffa47967 X-Google-Attributes: gidf86c8,public X-Google-Language: SPANISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!easynet-monga!easynet.net!easynet-post1!not-for-mail Newsgroups: es.comp.os.linux.programacion Subject: Re: ¿Se puede cargar el intérprete de Perl como un servidor? References: <slrnd5s5b3.prl.gorka@conn.helvete.escomposlinux.org> From: Pascal Bourguignon <spam@mouse-potato.com> Date: 14 Apr 2005 12:53:07 +0200 Message-ID: <87u0m9bpf0.fsf@thalassa.informatimago.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Lines: 95 Organization: [posted via Easynet Spain] NNTP-Posting-Host: 62.93.174.79 X-Trace: DXC=QjD29A;nV=:=\fT^dGeSb;0mDM\=e`Rh8m9FY3?HjZ50