Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.

Ticket #3216: 3216.patch

File 3216.patch, 3.2 KB (added by jmoore, 14 years ago)
  • components/tools/OmeroPy/src/omero/plugins/web.py

    From 5b9341940774f1c168f550f0af6c576bb64b2731 Mon Sep 17 00:00:00 2001
    From: Josh <josh@glencoesoftware.com>
    Date: Wed, 3 Nov 2010 11:49:37 +0100
    Subject: [PATCH] Possible fix for double bin/omero web start invocations (See #3216)
    
    ---
     components/tools/OmeroPy/src/omero/plugins/web.py |   48 ++++++++++++++++-----
     1 files changed, 37 insertions(+), 11 deletions(-)
    
    diff --git a/components/tools/OmeroPy/src/omero/plugins/web.py b/components/tools/OmeroPy/src/omero/plugins/web.py
    index 70de352..1d7f3c0 100755
    a b Alias / "%(ROOT)s/var/omero.fcgi/" 
    261261                             getattr(settings, 'CACHE_BACKEND')) 
    262262                return 1 
    263263        deploy = getattr(settings, 'APPLICATION_SERVER') 
     264 
     265        # 3216 
     266        if deploy in (settings.FASTCGI_TYPES): 
     267            pid_path = self.ctx.dir / "var" / "django.pid" 
     268            pid_num = None 
     269 
     270            if pid_path.exists(): 
     271                pid_txt = pid_path.text().strip() 
     272                try: 
     273                    pid_num = int(pid_txt) 
     274                except: 
     275                    pid_path.remove() 
     276                    self.ctx.err("Removed invalid %s: '%s'" % (pid_path, pid_txt)) 
     277 
     278            if pid_num is not None: 
     279                try: 
     280                    os.kill(pid_num, 0) 
     281                    self.ctx.die(606, "%s exists! Use 'web stop' first" % pid_path) 
     282                except OSError: 
     283                    pid_path.remove() 
     284                    self.ctx.err("Removed stale %s" % pid_path) 
     285 
    264286        if deploy == settings.FASTCGI: 
    265287            cmd = "python manage.py runfcgi workdir=./" 
    266288            cmd += " method=prefork socket=%(base)s/var/django_fcgi.sock" 
    Alias / "%(ROOT)s/var/omero.fcgi/" 
    319341        deploy = getattr(settings, 'APPLICATION_SERVER') 
    320342        if deploy in settings.FASTCGI_TYPES: 
    321343            pid = 'Unknown' 
     344            pid_path = self.ctx.dir / "var" / "django.pid" 
     345            pid_text = pid_path.text().strip() 
    322346            try: 
    323                 f=open(self.ctx.dir / "var" / "django.pid", 'r') 
    324                 pid = int(f.read()) 
    325                 import signal 
    326                 os.kill(pid, 0)  # NULL signal 
    327             except: 
    328                 self.ctx.out("[FAILED]") 
    329                 self.ctx.out("Django FastCGI workers (PID %s) not started?" % pid) 
    330                 return 
    331             os.kill(pid, signal.SIGTERM) #kill whole group 
    332             self.ctx.out("[OK]") 
    333             self.ctx.out("Django FastCGI workers (PID %d) killed." % pid) 
     347                try: 
     348                    pid = int(pid_text) 
     349                    import signal 
     350                    os.kill(pid, 0)  # NULL signal 
     351                except: 
     352                    self.ctx.out("[FAILED]") 
     353                    self.ctx.out("Django FastCGI workers (PID %s) not started?" % pid_text) 
     354                    return 
     355                os.kill(pid, signal.SIGTERM) #kill whole group 
     356                self.ctx.out("[OK]") 
     357                self.ctx.out("Django FastCGI workers (PID %d) killed." % pid) 
     358            finally: 
     359                pid_path.remove() 
    334360        else: 
    335361            self.ctx.err("DEVELOPMENT: You will have to kill processes by hand!") 
    336362 

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.7933 sec.)

We're Hiring!