forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-queue-worker-reload
executable file
·86 lines (74 loc) · 2.5 KB
/
test-queue-worker-reload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import time
import signal
import subprocess
import re
from six.moves import range
# check for the venv
from lib import sanity_check
sanity_check.check_venv(__file__)
from typing import IO, Text
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
successful_worker_launches = [
'launching queue worker thread error_reports',
'launching queue worker thread user_presence',
'launching queue worker thread digest_emails',
'launching queue worker thread slow_queries',
'launching queue worker thread missedmessage_mobile_notifications',
'launching queue worker thread feedback_messages',
'launching queue worker thread signups',
'launching queue worker thread test',
'launching queue worker thread message_sender',
'launching queue worker thread missedmessage_emails',
'launching queue worker thread email_mirror',
'launching queue worker thread user_activity_interval',
'launching queue worker thread invites',
'launching queue worker thread user_activity'
]
def check_worker_launch(logfile):
# type: (IO) -> Text
def check(content):
# type: (str) -> bool
flag = True
for entry in successful_worker_launches:
flag = flag and entry in content
return flag
failed = True
log_output = u''
print("Polling logfile", end='')
# Attempt to poll the log file for 10 sec. to see if all worker threads are launched.
for i in range(100):
time.sleep(0.3)
sys.stdout.write('.')
sys.stdout.flush()
logfile.seek(0)
content = logfile.read()
log_output = content
if check(content):
failed = False
break
sys.stdout.write('\n')
if not failed:
print('Worker threads launched successfully')
return log_output
else:
print('Error in server startup. Dumping logs')
print(log_output)
sys.exit(1)
if __name__ == '__main__':
print('\nStarting Development Server')
logfile = open('/tmp/run-dev-output', 'w+')
args = ["{}/run-dev.py".format(TOOLS_DIR)]
run_dev = subprocess.Popen(args, stdout=logfile, stderr=logfile)
check_worker_launch(logfile)
logfile.truncate(0)
print("Attempting to modify a file")
subprocess.call(['touch', 'zerver/lib/actions.py'])
check_worker_launch(logfile)
run_dev.send_signal(signal.SIGINT)
run_dev.wait()
logfile.close()