@@ -27,8 +27,11 @@ def get_today() -> str:
27
27
return today
28
28
29
29
30
- def run_command_via_subprocess (cmd : list , cwd : str , output_lines : list = [],
31
- print : bool = False ) -> int :
30
+ def run_command_via_subprocess (cmd : list ,
31
+ cwd : str ,
32
+ output_lines : list = [],
33
+ print_to_log : bool = False
34
+ ) -> int :
32
35
"""Wraps around subprocess.Popen() to run commands outside of Python. Prints
33
36
output as it goes, returns the status code from the command.
34
37
@@ -40,7 +43,7 @@ def run_command_via_subprocess(cmd: list, cwd: str, output_lines: list=[],
40
43
Set the working directory, or to None.
41
44
output_lines : list
42
45
Pass in a list to return the output details.
43
- print : bool
46
+ print_to_log : bool
44
47
Default False. Set to true to also print to logger
45
48
46
49
Returns
@@ -60,12 +63,23 @@ def run_command_via_subprocess(cmd: list, cwd: str, output_lines: list=[],
60
63
if output :
61
64
ln = output .strip ().decode ('utf-8' )
62
65
output_lines .append (ln )
63
- if print :
66
+ if print_to_log :
64
67
logger .info (ln )
68
+
69
+ # Detects issue reported in https://github.com/rustprooflabs/pgosm-flex/issues/391
70
+ # Status code is incorrectly returned is 0, cannot detect
71
+ # problem using that method so forcing failure with custom
72
+ # status code.
73
+ if 'Error during diff download. Bailing out.' in ln :
74
+ logger .error ('Data in database is too far behind replication service.' )
75
+ return 999
76
+
65
77
else :
66
78
# Only sleep when there wasn't output
67
79
sleep (1 )
80
+
68
81
status = process .poll ()
82
+
69
83
return status
70
84
71
85
0 commit comments