-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
38 lines (29 loc) · 1.07 KB
/
run.py
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
import config
import googlecloudprofiler
import subprocess
from utils import wait_timeout, wait_timeout_extended
logger = config.set_logger('run.py')
def main():
# set_cloud_profiler()
logger.info('BEGINNING OF LITTER BUG SCRIPT RUN.PY...')
litter_bug = ['python3', config.BASE_PATH + 'main.py']
while True:
try:
logger.info('LAUNCHING NEW LITTER BUG...')
p = subprocess.Popen(litter_bug, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
wait_timeout_extended(p, config.LITTER_BUG_TIMEOUT, config.LITTER_BUG_INTERVAL)
except subprocess.CalledProcessError as e:
logger.error('Error has occurred in run.py')
logger.error(e)
# def set_cloud_profiler():
# logger.info("Setting cloud profiler...")
# try:
# googlecloudprofiler.start(
# service='plb-profiler',
# service_version='1.0.1',
# verbose=3,
# )
# except (ValueError, NotImplementedError) as exc:
# print(exc) # Handle errors here
if __name__ == '__main__':
main()