Projet

Général

Profil

Development #1280

Ajout d'une option max-children pour contrôler le nombre de workers

Ajouté par Benjamin Dauvergne il y a environ 12 ans. Mis à jour il y a plus de 8 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Version cible:
-
Début:
27 février 2012
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Planning:

Description

diff --git a/wcs/ctl/start.py b/wcs/ctl/start.py
index a9609c6..af008b2 100644
--- a/wcs/ctl/start.py
+++ b/wcs/ctl/start.py
@@ -17,7 +17,6 @@
 import socket
 import sys
 import qommon.scgi_server
-import quixote.server.simple_server

 from qommon.ctl import Command, make_option

@@ -37,6 +36,9 @@ class CmdStart(Command):
                             dest='http', default=False),
                 make_option('--silent', action='store_true',
                             dest='silent', default=False),
+                make_option('--max-children', metavar='MAX_CHILDREN',
+                            type='int', action='store', dest='max_children',
+                            default=6)
                 ])

     def execute(self, base_options, sub_options, args):
@@ -51,6 +53,8 @@ class CmdStart(Command):
             run_kwargs['handler_connection_limit'] = int(sub_options.handler_connection_limit)
         if sub_options.script_name:
             run_kwargs['script_name'] = sub_options.script_name
+        if sub_options.max_children:
+            run_kwargs['max_children'] = sub_options.max_children
         if sub_options.http:
             run_function = qommon.scgi_server.http_run
         if sub_options.silent:

Demandes liées

Lié à Au quotidien - Bug #1283: crash "504 gateway time-out"Fermé28 février 2012

Actions

Historique

#1

Mis à jour par Jérôme Schneider il y a environ 12 ans

Je viens de tester le patch et ça marche bien. J'hésite à rajouter l'option dans le fichier de conf mais je ne pense que ça soit nécessaire.

#2

Mis à jour par Frédéric Péters il y a environ 12 ans

Oh beh si ce serait bien, dans le fichier de config :)

#3

Mis à jour par Benjamin Dauvergne il y a environ 12 ans

Compliqué:


diff --git a/wcs/ctl/start.py b/wcs/ctl/start.py
index a9609c6..b7209fa 100644
--- a/wcs/ctl/start.py
+++ b/wcs/ctl/start.py
@@ -17,7 +17,6 @@
 import socket
 import sys
 import qommon.scgi_server
-import quixote.server.simple_server

 from qommon.ctl import Command, make_option

@@ -30,13 +29,16 @@ class CmdStart(Command):
                             dest='port', default=3001),
                 make_option('--handler-connection-limit', metavar='LIMIT',
                             action='store',
-                            dest='handler_connection_limit', default=None),
+                            dest='handler_connection_limit', type='int',
+                            default=-1),
                 make_option('--script-name', metavar='NAME', action='store',
                             dest='script_name', default=None),
                 make_option('--http', action='store_true',
                             dest='http', default=False),
                 make_option('--silent', action='store_true',
                             dest='silent', default=False),
+                make_option('--max-children', metavar='MAX_CHILDREN',
+                            type='int', action='store', dest='max_children')
                 ])

     def execute(self, base_options, sub_options, args):
@@ -47,16 +49,19 @@ class CmdStart(Command):
         run_kwargs['spawn_cron'] = True
         run_function = qommon.scgi_server.run
         publisher.WcsPublisher.configure(self.config, sub_options.extra)
-        if sub_options.handler_connection_limit:
-            run_kwargs['handler_connection_limit'] = int(sub_options.handler_connection_limit)
         if sub_options.script_name:
             run_kwargs['script_name'] = sub_options.script_name
+        run_kwargs['handler_connection_limit'] = self.get_option(sub_options,
+                'handler_connection_limit')
+        run_kwargs['max_children'] = self.get_option(sub_options,
+                'max_children', default=6)
         if sub_options.http:
             run_function = qommon.scgi_server.http_run
         if sub_options.silent:
             sys.stdout = file('/dev/null', 'w')
             sys.stderr = file('/dev/null', 'w')

+        print 'run_kwargs', run_kwargs
         try:
             run_function(publisher.WcsPublisher.create_publisher, **run_kwargs)
         except socket.error, e:
diff --git a/wcs/qommon/ctl.py b/wcs/qommon/ctl.py
index c97733a..0541da0 100644
--- a/wcs/qommon/ctl.py
+++ b/wcs/qommon/ctl.py
@@ -19,6 +19,7 @@ import optparse
 from optparse import make_option
 import sys
 import os
+import __builtin__

 __all__ = [
     'Command',
@@ -44,6 +45,20 @@ class Command:
                         dest='data_dir', default=None),
                     ]

+    def get_option(self, sub_options, argname, default=None):
+        for option in self.options:
+            if option.dest == argname:
+                break
+        else:
+            raise ValueError('no argument by this name', argname)
+        v = getattr(sub_options, argname, None)
+        if v:
+            return v
+        _type = option.type or 'string'
+        if self.config.has_option('main', argname):
+            return getattr(__builtin__, _type)(self.config.get('main', argname))
+        return default
+
     def run(self, args, base_options):
         if base_options.configfile:
             if not os.path.exists(base_options.configfile):

ou alors simple:


diff --git a/wcs/ctl/start.py b/wcs/ctl/start.py
index a9609c6..39af929 100644
--- a/wcs/ctl/start.py
+++ b/wcs/ctl/start.py
@@ -17,7 +17,6 @@
 import socket
 import sys
 import qommon.scgi_server
-import quixote.server.simple_server

 from qommon.ctl import Command, make_option

@@ -37,6 +36,8 @@ class CmdStart(Command):
                             dest='http', default=False),
                 make_option('--silent', action='store_true',
                             dest='silent', default=False),
+                make_option('--max-children', metavar='MAX_CHILDREN',
+                            type='int', action='store', dest='max_children')
                 ])

     def execute(self, base_options, sub_options, args):
@@ -51,6 +52,10 @@ class CmdStart(Command):
             run_kwargs['handler_connection_limit'] = int(sub_options.handler_connection_limit)
         if sub_options.script_name:
             run_kwargs['script_name'] = sub_options.script_name
+        if sub_options.max_children:
+            run_kwargs['max_children'] = sub_options.max_children
+        if self.config.has_option('main', 'max_children'):
+            run_kwargs['max_children'] = self.config.getint('main', 'max_children')
         if sub_options.http:
             run_function = qommon.scgi_server.http_run
         if sub_options.silent:

#4

Mis à jour par Benjamin Dauvergne il y a environ 12 ans

Celui là donne bien la priorité à l'option de ligne de commande:

diff --git a/wcs/ctl/start.py b/wcs/ctl/start.py
index a9609c6..5e4d9d6 100644
--- a/wcs/ctl/start.py
+++ b/wcs/ctl/start.py
@@ -17,7 +17,6 @@
 import socket
 import sys
 import qommon.scgi_server
-import quixote.server.simple_server

 from qommon.ctl import Command, make_option

@@ -37,6 +36,8 @@ class CmdStart(Command):
                             dest='http', default=False),
                 make_option('--silent', action='store_true',
                             dest='silent', default=False),
+                make_option('--max-children', metavar='MAX_CHILDREN',
+                            type='int', action='store', dest='max_children')
                 ])

     def execute(self, base_options, sub_options, args):
@@ -51,6 +52,10 @@ class CmdStart(Command):
             run_kwargs['handler_connection_limit'] = int(sub_options.handler_connection_limit)
         if sub_options.script_name:
             run_kwargs['script_name'] = sub_options.script_name
+        if sub_options.max_children:
+            run_kwargs['max_children'] = sub_options.max_children
+        elif self.config.has_option('main', 'max_children'):
+            run_kwargs['max_children'] = self.config.getint('main', 'max_children')
         if sub_options.http:
             run_function = qommon.scgi_server.http_run
         if sub_options.silent:

#5

Mis à jour par Frédéric Péters il y a environ 12 ans

  • Statut changé de Solution déployée à Résolu (à déployer)

Voilà, j'ai poussé la version simple en ton nom.

#6

Mis à jour par Frédéric Péters il y a presque 11 ans

  • % réalisé changé de 0 à 100
#7

Mis à jour par Frédéric Péters il y a presque 11 ans

  • Statut changé de Résolu (à déployer) à Fermé
#8

Mis à jour par Thomas Noël il y a plus de 8 ans

  • Version cible Au-quotidien 2012.2 supprimé

Formats disponibles : Atom PDF