Switch to unified view

a/Allura/allura/command/base.py b/Allura/allura/command/base.py
1
import os
1
import os
2
import sys
2
import sys
3
import logging
3
import logging
4
from multiprocessing import Process
4
from pkg_resources import iter_entry_points
5
from pkg_resources import iter_entry_points
5
6
6
import pylons
7
import pylons
7
from paste.script import command
8
from paste.script import command
8
from paste.deploy import appconfig
9
from paste.deploy import appconfig
...
...
77
        self.registry.register(allura.credentials, allura.lib.security.Credentials())
78
        self.registry.register(allura.credentials, allura.lib.security.Credentials())
78
        pylons.c.queued_messages = None
79
        pylons.c.queued_messages = None
79
80
80
    def teardown_globals(self):
81
    def teardown_globals(self):
81
        self.registry.cleanup()
82
        self.registry.cleanup()
83
84
class RestartableProcess(object):
85
86
    def __init__(self, log, *args, **kwargs):
87
        self._log = log
88
        self._args, self._kwargs = args, kwargs
89
        self.reinit()
90
91
    def reinit(self):
92
        self._process = Process(*self._args, **self._kwargs)
93
94
    def check(self):
95
        if not self.is_alive():
96
            self._log.error('Process %d has died, restarting', self.pid)
97
            self.reinit()
98
            self.start()
99
100
    def __getattr__(self, name):
101
        return getattr(self._process, name)