meerschaum 2.3.0.dev3__py3-none-any.whl → 2.3.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meerschaum/__init__.py +3 -2
- meerschaum/__main__.py +0 -5
- meerschaum/_internal/arguments/_parser.py +6 -2
- meerschaum/_internal/entry.py +36 -6
- meerschaum/_internal/shell/Shell.py +32 -20
- meerschaum/actions/attach.py +12 -7
- meerschaum/actions/copy.py +68 -41
- meerschaum/actions/delete.py +64 -21
- meerschaum/actions/edit.py +3 -3
- meerschaum/actions/install.py +40 -32
- meerschaum/actions/pause.py +44 -27
- meerschaum/actions/restart.py +107 -0
- meerschaum/actions/show.py +8 -8
- meerschaum/actions/start.py +25 -40
- meerschaum/actions/stop.py +11 -4
- meerschaum/api/_events.py +10 -3
- meerschaum/api/dash/jobs.py +69 -70
- meerschaum/api/routes/_actions.py +8 -3
- meerschaum/api/routes/_jobs.py +37 -19
- meerschaum/config/_default.py +1 -1
- meerschaum/config/_paths.py +5 -0
- meerschaum/config/_version.py +1 -1
- meerschaum/config/static/__init__.py +3 -0
- meerschaum/connectors/Connector.py +13 -7
- meerschaum/connectors/__init__.py +21 -5
- meerschaum/connectors/api/APIConnector.py +3 -0
- meerschaum/connectors/api/_jobs.py +30 -3
- meerschaum/connectors/parse.py +10 -13
- meerschaum/core/Pipe/_bootstrap.py +16 -8
- meerschaum/jobs/_Executor.py +69 -0
- meerschaum/{utils/jobs → jobs}/_Job.py +160 -20
- meerschaum/jobs/_LocalExecutor.py +88 -0
- meerschaum/jobs/_SystemdExecutor.py +608 -0
- meerschaum/jobs/__init__.py +365 -0
- meerschaum/plugins/__init__.py +6 -6
- meerschaum/utils/daemon/Daemon.py +7 -0
- meerschaum/utils/daemon/RotatingFile.py +5 -2
- meerschaum/utils/daemon/StdinFile.py +12 -2
- meerschaum/utils/daemon/__init__.py +2 -0
- meerschaum/utils/formatting/_jobs.py +52 -16
- meerschaum/utils/misc.py +23 -5
- meerschaum/utils/packages/_packages.py +7 -4
- meerschaum/utils/process.py +9 -9
- meerschaum/utils/venv/__init__.py +2 -2
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/METADATA +14 -17
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/RECORD +52 -48
- meerschaum/utils/jobs/__init__.py +0 -245
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/LICENSE +0 -0
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/NOTICE +0 -0
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/WHEEL +0 -0
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/top_level.txt +0 -0
- {meerschaum-2.3.0.dev3.dist-info → meerschaum-2.3.0rc1.dist-info}/zip-safe +0 -0
meerschaum/actions/install.py
CHANGED
@@ -10,9 +10,9 @@ from __future__ import annotations
|
|
10
10
|
from meerschaum.utils.typing import List, Any, SuccessTuple, Optional, Union
|
11
11
|
|
12
12
|
def install(
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
action: Optional[List[str]] = None,
|
14
|
+
**kw: Any
|
15
|
+
) -> SuccessTuple:
|
16
16
|
"""
|
17
17
|
Install Meerschaum plugins or Python packages.
|
18
18
|
"""
|
@@ -26,9 +26,9 @@ def install(
|
|
26
26
|
|
27
27
|
|
28
28
|
def _complete_install(
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
action: Optional[List[str]] = None,
|
30
|
+
**kw: Any
|
31
|
+
) -> List[str]:
|
32
32
|
"""
|
33
33
|
Override the default Meerschaum `complete_` function.
|
34
34
|
"""
|
@@ -52,13 +52,13 @@ def _complete_install(
|
|
52
52
|
|
53
53
|
|
54
54
|
def _install_plugins(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
action: Optional[List[str]] = None,
|
56
|
+
repository: Optional[str] = None,
|
57
|
+
skip_deps: bool = False,
|
58
|
+
force: bool = False,
|
59
|
+
debug: bool = False,
|
60
|
+
**kw: Any
|
61
|
+
) -> SuccessTuple:
|
62
62
|
"""
|
63
63
|
Install a plugin.
|
64
64
|
|
@@ -103,10 +103,10 @@ def _install_plugins(
|
|
103
103
|
|
104
104
|
|
105
105
|
def _complete_install_plugins(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
action: Optional[List[str]] = None,
|
107
|
+
repository: Optional[str] = None,
|
108
|
+
**kw: Any
|
109
|
+
) -> List[str]:
|
110
110
|
"""
|
111
111
|
Search for plugins to autocomplete command line text.
|
112
112
|
NOTE: Disabled for the time being so we don't interrupt the user typing.
|
@@ -143,12 +143,12 @@ class NoVenv:
|
|
143
143
|
pass
|
144
144
|
|
145
145
|
def _install_packages(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
action: Optional[List[str]] = None,
|
147
|
+
sub_args: Optional[List[str]] = None,
|
148
|
+
venv: Union[str, NoVenv] = NoVenv,
|
149
|
+
debug: bool = False,
|
150
|
+
**kw: Any
|
151
|
+
) -> SuccessTuple:
|
152
152
|
"""
|
153
153
|
Install PyPI packages into the Meerschaum virtual environment.
|
154
154
|
|
@@ -179,19 +179,17 @@ def _install_packages(
|
|
179
179
|
)
|
180
180
|
|
181
181
|
|
182
|
-
def _complete_install_packages(
|
183
|
-
**kw : Any
|
184
|
-
) -> List[str]:
|
182
|
+
def _complete_install_packages(**kw : Any) -> List[str]:
|
185
183
|
return []
|
186
184
|
|
187
185
|
|
188
186
|
def _install_required(
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
187
|
+
action: Optional[List[str]] = None,
|
188
|
+
repository: Optional[str] = None,
|
189
|
+
force: bool = False,
|
190
|
+
debug: bool = False,
|
191
|
+
**kw
|
192
|
+
) -> SuccessTuple:
|
195
193
|
"""
|
196
194
|
Install the required packages for Meerschaum plugins.
|
197
195
|
Each plugin's packages will be installed into its virtual environment.
|
@@ -237,6 +235,16 @@ def _complete_install_required(*args, **kw) -> List[str]:
|
|
237
235
|
return _complete_uninstall_plugins(*args, **kw)
|
238
236
|
|
239
237
|
|
238
|
+
def _install_systemd(
|
239
|
+
action: Optional[List[str]] = None,
|
240
|
+
**kwargs: Any
|
241
|
+
) -> SuccessTuple:
|
242
|
+
"""
|
243
|
+
Install the Meerschaum job monitor as a systemd service.
|
244
|
+
"""
|
245
|
+
import sys
|
246
|
+
|
247
|
+
|
240
248
|
### NOTE: This must be the final statement of the module.
|
241
249
|
### Any subactions added below these lines will not
|
242
250
|
### be added to the `help` docstring.
|
meerschaum/actions/pause.py
CHANGED
@@ -27,13 +27,20 @@ def _complete_pause(
|
|
27
27
|
"""
|
28
28
|
Override the default Meerschaum `complete_` function.
|
29
29
|
"""
|
30
|
-
from meerschaum.actions.
|
30
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
31
|
+
from functools import partial
|
32
|
+
|
31
33
|
if action is None:
|
32
34
|
action = []
|
33
35
|
|
36
|
+
_complete_pause_jobs = partial(
|
37
|
+
_complete_delete_jobs,
|
38
|
+
_get_job_method='running',
|
39
|
+
)
|
40
|
+
|
34
41
|
options = {
|
35
|
-
'job'
|
36
|
-
'jobs'
|
42
|
+
'job': _complete_pause_jobs,
|
43
|
+
'jobs': _complete_pause_jobs,
|
37
44
|
}
|
38
45
|
|
39
46
|
if (
|
@@ -49,43 +56,53 @@ def _complete_pause(
|
|
49
56
|
|
50
57
|
|
51
58
|
def _pause_jobs(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
action: Optional[List[str]] = None,
|
60
|
+
executor_keys: Optional[str] = None,
|
61
|
+
noask: bool = False,
|
62
|
+
force: bool = False,
|
63
|
+
yes: bool = False,
|
64
|
+
nopretty: bool = False,
|
65
|
+
debug: bool = False,
|
66
|
+
**kw
|
67
|
+
) -> SuccessTuple:
|
59
68
|
"""
|
60
|
-
Pause running jobs
|
61
|
-
|
62
|
-
To see running jobs, run `show jobs`.
|
69
|
+
Pause (suspend) running jobs.
|
63
70
|
"""
|
64
71
|
from meerschaum.utils.formatting._jobs import pprint_jobs
|
65
72
|
from meerschaum.utils.daemon import (
|
66
73
|
get_filtered_daemons, get_running_daemons, get_stopped_daemons, get_paused_daemons,
|
67
74
|
)
|
75
|
+
from meerschaum.jobs import (
|
76
|
+
get_filtered_jobs,
|
77
|
+
get_running_jobs,
|
78
|
+
get_stopped_jobs,
|
79
|
+
get_paused_jobs,
|
80
|
+
)
|
68
81
|
from meerschaum.utils.warnings import warn
|
69
82
|
from meerschaum.utils.prompt import yes_no
|
70
83
|
from meerschaum.utils.misc import items_str
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
84
|
+
|
85
|
+
jobs = get_filtered_jobs(executor_keys, action, debug=debug, warn=(not nopretty))
|
86
|
+
running_jobs = get_running_jobs(executor_keys, jobs, debug=debug)
|
87
|
+
paused_jobs = get_paused_jobs(executor_keys, jobs, debug=debug)
|
88
|
+
stopped_jobs = get_stopped_jobs(executor_keys, jobs, debug=debug)
|
89
|
+
|
90
|
+
if action and stopped_jobs and not nopretty:
|
76
91
|
warn(
|
77
|
-
f"Skipping stopped job" + ("s" if len(
|
78
|
-
|
79
|
-
|
92
|
+
f"Skipping stopped job" + ("s" if len(stopped_jobs) > 1 else '')
|
93
|
+
+ " '"
|
94
|
+
+ ("', '".join(stopped_jobs.keys()))
|
95
|
+
+ "'.",
|
96
|
+
stack=False,
|
80
97
|
)
|
81
98
|
|
82
|
-
|
83
|
-
if not
|
99
|
+
jobs_to_pause = {**running_jobs, **paused_jobs}
|
100
|
+
if not jobs_to_pause:
|
84
101
|
return False, "No running jobs to pause. You can start jobs with `-d` or `start jobs`."
|
85
102
|
|
86
103
|
if not action:
|
87
104
|
if not force:
|
88
|
-
pprint_jobs(
|
105
|
+
pprint_jobs(running_jobs)
|
89
106
|
if not yes_no(
|
90
107
|
"Pause all running jobs?",
|
91
108
|
noask=noask, yes=yes, default='n'
|
@@ -93,9 +110,9 @@ def _pause_jobs(
|
|
93
110
|
return False, "No jobs were paused."
|
94
111
|
|
95
112
|
successes, fails = [], []
|
96
|
-
for
|
97
|
-
pause_success, pause_msg =
|
98
|
-
(successes if pause_success else fails).append(
|
113
|
+
for name, job in jobs_to_pause.items():
|
114
|
+
pause_success, pause_msg = job.pause()
|
115
|
+
(successes if pause_success else fails).append(name)
|
99
116
|
|
100
117
|
msg = (
|
101
118
|
(
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env python3
|
2
|
+
# vim:fenc=utf-8
|
3
|
+
|
4
|
+
"""
|
5
|
+
Restart stopped jobs which have not been manually stopped.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from meerschaum.utils.typing import SuccessTuple, Optional, List, Any
|
9
|
+
|
10
|
+
def restart(
|
11
|
+
action: Optional[List[str]] = None,
|
12
|
+
executor_keys: Optional[str] = None,
|
13
|
+
**kwargs: Any
|
14
|
+
) -> SuccessTuple:
|
15
|
+
"""
|
16
|
+
Restart stopped jobs which have not been manually stopped.
|
17
|
+
"""
|
18
|
+
from meerschaum.actions import choose_subaction
|
19
|
+
attach_options = {
|
20
|
+
'jobs': _restart_jobs,
|
21
|
+
}
|
22
|
+
return choose_subaction(action, attach_options, executor_keys=executor_keys, **kwargs)
|
23
|
+
|
24
|
+
|
25
|
+
def _complete_restart(
|
26
|
+
action: Optional[List[str]] = None,
|
27
|
+
**kw: Any
|
28
|
+
) -> List[str]:
|
29
|
+
"""
|
30
|
+
Override the default Meerschaum `complete_` function.
|
31
|
+
"""
|
32
|
+
from functools import partial
|
33
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
34
|
+
|
35
|
+
if action is None:
|
36
|
+
action = []
|
37
|
+
|
38
|
+
_complete_restart_jobs = partial(
|
39
|
+
_complete_delete_jobs,
|
40
|
+
_get_job_method='restart',
|
41
|
+
)
|
42
|
+
|
43
|
+
options = {
|
44
|
+
'job': _complete_restart_jobs,
|
45
|
+
'jobs': _complete_restart_jobs,
|
46
|
+
}
|
47
|
+
|
48
|
+
if (
|
49
|
+
len(action) > 0 and action[0] in options
|
50
|
+
and kw.get('line', '').split(' ')[-1] != action[0]
|
51
|
+
):
|
52
|
+
sub = action[0]
|
53
|
+
del action[0]
|
54
|
+
return options[sub](action=action, **kw)
|
55
|
+
|
56
|
+
from meerschaum._internal.shell import default_action_completer
|
57
|
+
return default_action_completer(action=(['restart'] + action), **kw)
|
58
|
+
|
59
|
+
|
60
|
+
def _restart_jobs(
|
61
|
+
action: Optional[List[str]] = None,
|
62
|
+
executor_keys: Optional[str] = None,
|
63
|
+
loop: bool = False,
|
64
|
+
min_seconds: Optional[float] = 1.0,
|
65
|
+
debug: bool = False,
|
66
|
+
**kwargs: Any
|
67
|
+
) -> SuccessTuple:
|
68
|
+
"""
|
69
|
+
Restart stopped jobs which have not been manually stopped.
|
70
|
+
"""
|
71
|
+
import time
|
72
|
+
from meerschaum.jobs import (
|
73
|
+
get_restart_jobs,
|
74
|
+
get_filtered_jobs,
|
75
|
+
check_restart_jobs,
|
76
|
+
)
|
77
|
+
from meerschaum.utils.misc import items_str
|
78
|
+
from meerschaum.utils.warnings import info
|
79
|
+
action = action or []
|
80
|
+
|
81
|
+
while True:
|
82
|
+
jobs = get_filtered_jobs(executor_keys, action, include_hidden=True, debug=debug)
|
83
|
+
restart_jobs = get_restart_jobs(executor_keys, jobs, debug=debug) if not action else jobs
|
84
|
+
if not restart_jobs and not loop:
|
85
|
+
return True, "No jobs need to be restarted."
|
86
|
+
|
87
|
+
info(
|
88
|
+
"Checking job"
|
89
|
+
+ ('s' if len(restart_jobs) != 1 else '')
|
90
|
+
+ ' '
|
91
|
+
+ items_str(list(restart_jobs.keys()))
|
92
|
+
+ '...'
|
93
|
+
)
|
94
|
+
|
95
|
+
check_success, check_msg = check_restart_jobs(
|
96
|
+
executor_keys,
|
97
|
+
restart_jobs,
|
98
|
+
debug=debug,
|
99
|
+
)
|
100
|
+
if not loop:
|
101
|
+
break
|
102
|
+
|
103
|
+
if min_seconds is not None and min_seconds != 0.0:
|
104
|
+
info(f"Sleeping for {min_seconds} seconds...")
|
105
|
+
time.sleep(min_seconds)
|
106
|
+
|
107
|
+
return check_success, check_msg
|
meerschaum/actions/show.py
CHANGED
@@ -54,7 +54,7 @@ def _complete_show(
|
|
54
54
|
"""
|
55
55
|
Override the default Meerschaum `complete_` function.
|
56
56
|
"""
|
57
|
-
from meerschaum.actions.
|
57
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
58
58
|
|
59
59
|
if action is None:
|
60
60
|
action = []
|
@@ -65,10 +65,10 @@ def _complete_show(
|
|
65
65
|
'config' : _complete_show_config,
|
66
66
|
'package' : _complete_show_packages,
|
67
67
|
'packages' : _complete_show_packages,
|
68
|
-
'job' :
|
69
|
-
'jobs' :
|
70
|
-
'log' :
|
71
|
-
'logs' :
|
68
|
+
'job' : _complete_delete_jobs,
|
69
|
+
'jobs' : _complete_delete_jobs,
|
70
|
+
'log' : _complete_delete_jobs,
|
71
|
+
'logs' : _complete_delete_jobs,
|
72
72
|
}
|
73
73
|
|
74
74
|
if (
|
@@ -560,7 +560,7 @@ def _show_jobs(
|
|
560
560
|
"""
|
561
561
|
Show the currently running and stopped jobs.
|
562
562
|
"""
|
563
|
-
from meerschaum.
|
563
|
+
from meerschaum.jobs import get_filtered_jobs
|
564
564
|
from meerschaum.utils.formatting._jobs import pprint_jobs
|
565
565
|
|
566
566
|
jobs = get_filtered_jobs(executor_keys, action, debug=debug)
|
@@ -575,7 +575,7 @@ def _show_jobs(
|
|
575
575
|
" - start api -d\n" +
|
576
576
|
" - start job sync pipes --loop"
|
577
577
|
)
|
578
|
-
return
|
578
|
+
return True, "No jobs to show."
|
579
579
|
|
580
580
|
pprint_jobs(jobs, nopretty=nopretty)
|
581
581
|
return True, "Success"
|
@@ -602,7 +602,7 @@ def _show_logs(
|
|
602
602
|
from functools import partial
|
603
603
|
from datetime import datetime, timezone
|
604
604
|
from meerschaum.utils.packages import attempt_import, import_rich
|
605
|
-
from meerschaum.
|
605
|
+
from meerschaum.jobs import get_filtered_jobs, Job
|
606
606
|
from meerschaum.utils.warnings import warn, info
|
607
607
|
from meerschaum.utils.formatting import get_console, ANSI, UNICODE
|
608
608
|
from meerschaum.utils.misc import tail
|
meerschaum/actions/start.py
CHANGED
@@ -10,9 +10,9 @@ from __future__ import annotations
|
|
10
10
|
from meerschaum.utils.typing import SuccessTuple, Optional, List, Any
|
11
11
|
|
12
12
|
def start(
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
action: Optional[List[str]] = None,
|
14
|
+
**kw: Any,
|
15
|
+
) -> SuccessTuple:
|
16
16
|
"""
|
17
17
|
Start subsystems (API server, background job, etc.).
|
18
18
|
"""
|
@@ -28,16 +28,23 @@ def start(
|
|
28
28
|
|
29
29
|
|
30
30
|
def _complete_start(
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
action: Optional[List[str]] = None,
|
32
|
+
**kw: Any
|
33
|
+
) -> List[str]:
|
34
34
|
"""
|
35
35
|
Override the default Meerschaum `complete_` function.
|
36
36
|
"""
|
37
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
38
|
+
from functools import partial
|
37
39
|
|
38
40
|
if action is None:
|
39
41
|
action = []
|
40
42
|
|
43
|
+
_complete_start_jobs = partial(
|
44
|
+
_complete_delete_jobs,
|
45
|
+
_get_job_method=['stopped', 'paused'],
|
46
|
+
)
|
47
|
+
|
41
48
|
options = {
|
42
49
|
'job': _complete_start_jobs,
|
43
50
|
'jobs': _complete_start_jobs,
|
@@ -76,13 +83,13 @@ def _start_api(action: Optional[List[str]] = None, **kw):
|
|
76
83
|
return actions['api'](action=['start'], **kw)
|
77
84
|
|
78
85
|
def _start_jobs(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
+
action: Optional[List[str]] = None,
|
87
|
+
name: Optional[str] = None,
|
88
|
+
sysargs: Optional[List[str]] = None,
|
89
|
+
executor_keys: Optional[str] = None,
|
90
|
+
debug: bool = False,
|
91
|
+
**kw
|
92
|
+
) -> SuccessTuple:
|
86
93
|
"""
|
87
94
|
Run a Meerschaum action as a background job.
|
88
95
|
|
@@ -115,7 +122,7 @@ def _start_jobs(
|
|
115
122
|
import textwrap
|
116
123
|
from meerschaum.utils.warnings import warn, info
|
117
124
|
from meerschaum.utils.daemon._names import get_new_daemon_name
|
118
|
-
from meerschaum.
|
125
|
+
from meerschaum.jobs import (
|
119
126
|
Job,
|
120
127
|
get_jobs,
|
121
128
|
get_filtered_jobs,
|
@@ -123,6 +130,7 @@ def _start_jobs(
|
|
123
130
|
get_running_jobs,
|
124
131
|
get_paused_jobs,
|
125
132
|
get_restart_jobs,
|
133
|
+
_install_healthcheck_job,
|
126
134
|
)
|
127
135
|
from meerschaum._internal.arguments._parse_arguments import parse_arguments
|
128
136
|
from meerschaum.actions import actions
|
@@ -133,7 +141,7 @@ def _start_jobs(
|
|
133
141
|
from meerschaum.utils.misc import items_str
|
134
142
|
|
135
143
|
names = []
|
136
|
-
jobs = get_filtered_jobs(executor_keys, debug=debug)
|
144
|
+
jobs = get_filtered_jobs(executor_keys, action, debug=debug)
|
137
145
|
|
138
146
|
new_job = len(list(action)) > 0
|
139
147
|
_potential_jobs = {'known': [], 'unknown': []}
|
@@ -166,7 +174,7 @@ def _start_jobs(
|
|
166
174
|
+ items_str(_potential_jobs['unknown'])
|
167
175
|
+ " will be ignored."
|
168
176
|
),
|
169
|
-
stack
|
177
|
+
stack=False
|
170
178
|
)
|
171
179
|
|
172
180
|
### Determine the `names` list.
|
@@ -294,33 +302,10 @@ def _start_jobs(
|
|
294
302
|
+ ("Failed to start job" + ("s" if len(_failures) != 1 else '')
|
295
303
|
+ f" {items_str(_failures)}." if _failures else '')
|
296
304
|
)
|
305
|
+
_install_healthcheck_job()
|
297
306
|
return len(_failures) == 0, msg
|
298
307
|
|
299
308
|
|
300
|
-
def _complete_start_jobs(
|
301
|
-
action: Optional[List[str]] = None,
|
302
|
-
executor_keys: Optional[str] = None,
|
303
|
-
line: str = '',
|
304
|
-
**kw
|
305
|
-
) -> List[str]:
|
306
|
-
from meerschaum.utils.jobs import get_filtered_jobs
|
307
|
-
jobs = get_filtered_jobs(executor_keys, action)
|
308
|
-
if not action:
|
309
|
-
return list(jobs)
|
310
|
-
|
311
|
-
possibilities = []
|
312
|
-
_line_end = line.split(' ')[-1]
|
313
|
-
for name in jobs:
|
314
|
-
if name in action:
|
315
|
-
continue
|
316
|
-
if _line_end == '':
|
317
|
-
possibilities.append(name)
|
318
|
-
continue
|
319
|
-
if name.startswith(action[-1]):
|
320
|
-
possibilities.append(name)
|
321
|
-
return possibilities
|
322
|
-
|
323
|
-
|
324
309
|
def _start_gui(
|
325
310
|
action: Optional[List[str]] = None,
|
326
311
|
mrsm_instance: Optional[str] = None,
|
meerschaum/actions/stop.py
CHANGED
@@ -27,13 +27,20 @@ def _complete_stop(
|
|
27
27
|
"""
|
28
28
|
Override the default Meerschaum `complete_` function.
|
29
29
|
"""
|
30
|
-
from meerschaum.actions.
|
30
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
31
|
+
from functools import partial
|
32
|
+
|
31
33
|
if action is None:
|
32
34
|
action = []
|
33
35
|
|
36
|
+
_complete_stop_jobs = partial(
|
37
|
+
_complete_delete_jobs,
|
38
|
+
_get_job_method=('running', 'paused', 'restart'),
|
39
|
+
)
|
40
|
+
|
34
41
|
options = {
|
35
|
-
'job' :
|
36
|
-
'jobs' :
|
42
|
+
'job' : _complete_stop_jobs,
|
43
|
+
'jobs' : _complete_stop_jobs,
|
37
44
|
}
|
38
45
|
|
39
46
|
if (
|
@@ -64,7 +71,7 @@ def _stop_jobs(
|
|
64
71
|
|
65
72
|
To see running processes, run `show jobs`.
|
66
73
|
"""
|
67
|
-
from meerschaum.
|
74
|
+
from meerschaum.jobs import (
|
68
75
|
get_filtered_jobs,
|
69
76
|
get_running_jobs,
|
70
77
|
get_paused_jobs,
|
meerschaum/api/_events.py
CHANGED
@@ -19,7 +19,11 @@ from meerschaum.utils.debug import dprint
|
|
19
19
|
from meerschaum.connectors.poll import retry_connect
|
20
20
|
from meerschaum.utils.warnings import warn
|
21
21
|
from meerschaum._internal.term.tools import is_webterm_running
|
22
|
-
from meerschaum.
|
22
|
+
from meerschaum.jobs import (
|
23
|
+
start_check_jobs_thread,
|
24
|
+
stop_check_jobs_thread,
|
25
|
+
get_executor_keys_from_context,
|
26
|
+
)
|
23
27
|
|
24
28
|
_check_jobs_thread = None
|
25
29
|
|
@@ -47,7 +51,8 @@ async def startup():
|
|
47
51
|
await shutdown()
|
48
52
|
os._exit(1)
|
49
53
|
|
50
|
-
|
54
|
+
if get_executor_keys_from_context() == 'local':
|
55
|
+
start_check_jobs_thread()
|
51
56
|
|
52
57
|
|
53
58
|
@app.on_event("shutdown")
|
@@ -60,7 +65,9 @@ async def shutdown():
|
|
60
65
|
if get_api_connector().type == 'sql':
|
61
66
|
get_api_connector().engine.dispose()
|
62
67
|
|
63
|
-
|
68
|
+
if get_executor_keys_from_context() == 'local':
|
69
|
+
stop_check_jobs_thread()
|
70
|
+
|
64
71
|
from meerschaum.api.routes._actions import _temp_jobs
|
65
72
|
for name, job in _temp_jobs.items():
|
66
73
|
job.delete()
|