コード例 #1
0
 def test_send(self):
     from supervisor.childutils import listener
     from supervisor.dispatchers import PEventListenerDispatcher
     begin = PEventListenerDispatcher.RESULT_TOKEN_START
     stdout = StringIO()
     msg = 'the body data ya fool\n'
     listener.send(msg, stdout)
     expected = '%s%s\n%s' % (begin, len(msg), msg)
     self.assertEqual(stdout.getvalue(), expected)
コード例 #2
0
ファイル: test_childutils.py プロジェクト: Davidwang79/minos
 def test_send(self):
     from supervisor.childutils import listener
     from supervisor.dispatchers import PEventListenerDispatcher
     begin = PEventListenerDispatcher.RESULT_TOKEN_START
     stdout = StringIO()
     msg = 'the body data ya fool\n'
     listener.send(msg, stdout)
     expected = '%s%s\n%s' % (begin, len(msg), msg)
     self.assertEqual(stdout.getvalue(), expected)
コード例 #3
0
ファイル: dbmon.py プロジェクト: apit/rinjani
def main():
    rpci = getRPCInterface(os.environ)

    while True:
        h, p = listener.wait()
        if not h['eventname'] == 'PROCESS_STATE_EXITED':
            listener.ok()
            continue

        ph, _pd = eventdata(p + '\n')
        if ph['processname'] == 'mongodb':
            if int(ph['expected']):
                listener.ok()
                continue

            listener.send("MONGODB HAS BEEN RESTARTED. SO WILL THE APP!")
            rpci.supervisor.stopProcessGroup('app')
            rpci.supervisor.startProcessGroup('app', True)
            listener.ok()
            now = datetime.now()
            send_twitter("[FATAL] %s - mongodb has been restarted" % now.isoformat())
            return

        listener.ok()