ominfra 0.0.0.dev137__py3-none-any.whl → 0.0.0.dev138__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- ominfra/manage/new/_manage.py +254 -157
- ominfra/manage/new/main.py +63 -13
- ominfra/pyremote.py +196 -145
- ominfra/scripts/supervisor.py +32 -31
- ominfra/supervisor/processimpl.py +32 -31
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/RECORD +11 -11
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev137.dist-info → ominfra-0.0.0.dev138.dist-info}/top_level.txt +0 -0
@@ -82,7 +82,7 @@ class ProcessImpl(Process):
|
|
82
82
|
self._backoff = 0 # backoff counter (to start_retries)
|
83
83
|
|
84
84
|
self._exitstatus: ta.Optional[Rc] = None # status attached to dead process by finish()
|
85
|
-
self._spawn_err: ta.Optional[str] = None # error message attached by
|
85
|
+
self._spawn_err: ta.Optional[str] = None # error message attached by _spawn() if any
|
86
86
|
|
87
87
|
#
|
88
88
|
|
@@ -119,12 +119,12 @@ class ProcessImpl(Process):
|
|
119
119
|
|
120
120
|
#
|
121
121
|
|
122
|
-
def
|
122
|
+
def _spawn(self) -> ta.Optional[Pid]:
|
123
123
|
if self.pid:
|
124
124
|
log.warning('process \'%s\' already running', self.name)
|
125
125
|
return None
|
126
126
|
|
127
|
-
self.
|
127
|
+
self._check_in_state(
|
128
128
|
ProcessState.EXITED,
|
129
129
|
ProcessState.FATAL,
|
130
130
|
ProcessState.BACKOFF,
|
@@ -139,15 +139,15 @@ class ProcessImpl(Process):
|
|
139
139
|
|
140
140
|
self._last_start = time.time()
|
141
141
|
|
142
|
-
self.
|
142
|
+
self._change_state(ProcessState.STARTING)
|
143
143
|
|
144
144
|
try:
|
145
145
|
sp = self._spawning.spawn()
|
146
146
|
except ProcessSpawnError as err:
|
147
147
|
log.exception('Spawn error')
|
148
148
|
self._spawn_err = err.args[0]
|
149
|
-
self.
|
150
|
-
self.
|
149
|
+
self._check_in_state(ProcessState.STARTING)
|
150
|
+
self._change_state(ProcessState.BACKOFF)
|
151
151
|
return None
|
152
152
|
|
153
153
|
log.info("Spawned: '%s' with pid %s", self.name, sp.pid)
|
@@ -180,7 +180,7 @@ class ProcessImpl(Process):
|
|
180
180
|
|
181
181
|
#
|
182
182
|
|
183
|
-
def
|
183
|
+
def _change_state(self, new_state: ProcessState, expected: bool = True) -> bool:
|
184
184
|
old_state = self._state
|
185
185
|
if new_state is old_state:
|
186
186
|
return False
|
@@ -198,7 +198,7 @@ class ProcessImpl(Process):
|
|
198
198
|
|
199
199
|
return True
|
200
200
|
|
201
|
-
def
|
201
|
+
def _check_in_state(self, *states: ProcessState) -> None:
|
202
202
|
if self._state not in states:
|
203
203
|
raise ProcessStateError(
|
204
204
|
f'Check failed for {self._config.name}: '
|
@@ -207,7 +207,7 @@ class ProcessImpl(Process):
|
|
207
207
|
|
208
208
|
#
|
209
209
|
|
210
|
-
def _check_and_adjust_for_system_clock_rollback(self, test_time):
|
210
|
+
def _check_and_adjust_for_system_clock_rollback(self, test_time: float) -> None:
|
211
211
|
"""
|
212
212
|
Check if system clock has rolled backward beyond test_time. If so, set affected timestamps to test_time.
|
213
213
|
"""
|
@@ -251,8 +251,8 @@ class ProcessImpl(Process):
|
|
251
251
|
self._delay = 0
|
252
252
|
self._backoff = 0
|
253
253
|
self._system_stop = True
|
254
|
-
self.
|
255
|
-
self.
|
254
|
+
self._check_in_state(ProcessState.BACKOFF)
|
255
|
+
self._change_state(ProcessState.FATAL)
|
256
256
|
|
257
257
|
def kill(self, sig: int) -> ta.Optional[str]:
|
258
258
|
"""
|
@@ -262,6 +262,7 @@ class ProcessImpl(Process):
|
|
262
262
|
Return None if the signal was sent, or an error message string if an error occurred or if the subprocess is not
|
263
263
|
running.
|
264
264
|
"""
|
265
|
+
|
265
266
|
now = time.time()
|
266
267
|
|
267
268
|
# If the process is in BACKOFF and we want to stop or kill it, then BACKOFF -> STOPPED. This is needed because
|
@@ -269,7 +270,7 @@ class ProcessImpl(Process):
|
|
269
270
|
# blocked for a long time waiting for the retries.
|
270
271
|
if self._state == ProcessState.BACKOFF:
|
271
272
|
log.debug('Attempted to kill %s, which is in BACKOFF state.', self.name)
|
272
|
-
self.
|
273
|
+
self._change_state(ProcessState.STOPPED)
|
273
274
|
return None
|
274
275
|
|
275
276
|
args: tuple
|
@@ -294,8 +295,8 @@ class ProcessImpl(Process):
|
|
294
295
|
self._killing = True
|
295
296
|
self._delay = now + self._config.stop_wait_secs
|
296
297
|
# we will already be in the STOPPING state if we're doing a SIGKILL as a result of overrunning stop_wait_secs
|
297
|
-
self.
|
298
|
-
self.
|
298
|
+
self._check_in_state(ProcessState.RUNNING, ProcessState.STARTING, ProcessState.STOPPING)
|
299
|
+
self._change_state(ProcessState.STOPPING)
|
299
300
|
|
300
301
|
kpid = int(self.pid)
|
301
302
|
if kill_as_group:
|
@@ -316,7 +317,7 @@ class ProcessImpl(Process):
|
|
316
317
|
tb = traceback.format_exc()
|
317
318
|
fmt, args = 'unknown problem killing %s (%s):%s', (self.name, self.pid, tb)
|
318
319
|
log.critical(fmt, *args)
|
319
|
-
self.
|
320
|
+
self._change_state(ProcessState.UNKNOWN)
|
320
321
|
self._killing = False
|
321
322
|
self._delay = 0
|
322
323
|
return fmt % args
|
@@ -338,7 +339,7 @@ class ProcessImpl(Process):
|
|
338
339
|
|
339
340
|
log.debug('sending %s (pid %s) sig %s', self.name, self.pid, sig_name(sig))
|
340
341
|
|
341
|
-
self.
|
342
|
+
self._check_in_state(ProcessState.RUNNING, ProcessState.STARTING, ProcessState.STOPPING)
|
342
343
|
|
343
344
|
try:
|
344
345
|
try:
|
@@ -359,7 +360,7 @@ class ProcessImpl(Process):
|
|
359
360
|
tb = traceback.format_exc()
|
360
361
|
fmt, args = 'unknown problem sending sig %s (%s):%s', (self.name, self.pid, tb)
|
361
362
|
log.critical(fmt, *args)
|
362
|
-
self.
|
363
|
+
self._change_state(ProcessState.UNKNOWN)
|
363
364
|
return fmt % args
|
364
365
|
|
365
366
|
return None
|
@@ -397,8 +398,8 @@ class ProcessImpl(Process):
|
|
397
398
|
self._exitstatus = Rc(es)
|
398
399
|
|
399
400
|
fmt, args = 'stopped: %s (%s)', (self.name, msg)
|
400
|
-
self.
|
401
|
-
self.
|
401
|
+
self._check_in_state(ProcessState.STOPPING)
|
402
|
+
self._change_state(ProcessState.STOPPED)
|
402
403
|
if exit_expected:
|
403
404
|
log.info(fmt, *args)
|
404
405
|
else:
|
@@ -408,8 +409,8 @@ class ProcessImpl(Process):
|
|
408
409
|
# the program did not stay up long enough to make it to RUNNING implies STARTING -> BACKOFF
|
409
410
|
self._exitstatus = None
|
410
411
|
self._spawn_err = 'Exited too quickly (process log may have details)'
|
411
|
-
self.
|
412
|
-
self.
|
412
|
+
self._check_in_state(ProcessState.STARTING)
|
413
|
+
self._change_state(ProcessState.BACKOFF)
|
413
414
|
log.warning('exited: %s (%s)', self.name, msg + '; not expected')
|
414
415
|
|
415
416
|
else:
|
@@ -422,18 +423,18 @@ class ProcessImpl(Process):
|
|
422
423
|
# if the process was STARTING but a system time change causes self.last_start to be in the future, the
|
423
424
|
# normal STARTING->RUNNING transition can be subverted so we perform the transition here.
|
424
425
|
if self._state == ProcessState.STARTING:
|
425
|
-
self.
|
426
|
+
self._change_state(ProcessState.RUNNING)
|
426
427
|
|
427
|
-
self.
|
428
|
+
self._check_in_state(ProcessState.RUNNING)
|
428
429
|
|
429
430
|
if exit_expected:
|
430
431
|
# expected exit code
|
431
|
-
self.
|
432
|
+
self._change_state(ProcessState.EXITED, expected=True)
|
432
433
|
log.info('exited: %s (%s)', self.name, msg + '; expected')
|
433
434
|
else:
|
434
435
|
# unexpected exit code
|
435
436
|
self._spawn_err = f'Bad exit code {es}'
|
436
|
-
self.
|
437
|
+
self._change_state(ProcessState.EXITED, expected=False)
|
437
438
|
log.warning('exited: %s (%s)', self.name, msg + '; not expected')
|
438
439
|
|
439
440
|
self._pid = Pid(0)
|
@@ -453,21 +454,21 @@ class ProcessImpl(Process):
|
|
453
454
|
if self._config.auto_restart:
|
454
455
|
if self._config.auto_restart is RestartUnconditionally:
|
455
456
|
# EXITED -> STARTING
|
456
|
-
self.
|
457
|
+
self._spawn()
|
457
458
|
elif self._exitstatus not in self._config.exitcodes:
|
458
459
|
# EXITED -> STARTING
|
459
|
-
self.
|
460
|
+
self._spawn()
|
460
461
|
|
461
462
|
elif state == ProcessState.STOPPED and not self._last_start:
|
462
463
|
if self._config.auto_start:
|
463
464
|
# STOPPED -> STARTING
|
464
|
-
self.
|
465
|
+
self._spawn()
|
465
466
|
|
466
467
|
elif state == ProcessState.BACKOFF:
|
467
468
|
if self._backoff <= self._config.start_retries:
|
468
469
|
if now > self._delay:
|
469
470
|
# BACKOFF -> STARTING
|
470
|
-
self.
|
471
|
+
self._spawn()
|
471
472
|
|
472
473
|
if state == ProcessState.STARTING:
|
473
474
|
if now - self._last_start > self._config.start_secs:
|
@@ -475,8 +476,8 @@ class ProcessImpl(Process):
|
|
475
476
|
# proc.config.start_secs,
|
476
477
|
self._delay = 0
|
477
478
|
self._backoff = 0
|
478
|
-
self.
|
479
|
-
self.
|
479
|
+
self._check_in_state(ProcessState.STARTING)
|
480
|
+
self._change_state(ProcessState.RUNNING)
|
480
481
|
msg = ('entered RUNNING state, process has stayed up for > than %s seconds (start_secs)' % self._config.start_secs) # noqa
|
481
482
|
log.info('success: %s %s', self.name, msg)
|
482
483
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev138
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omdev==0.0.0.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev138
|
16
|
+
Requires-Dist: omlish==0.0.0.dev138
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -3,7 +3,7 @@ ominfra/__about__.py,sha256=6i1AoruFYQCd-PyhhbDQDWY2d1tiQu9nkwWr-fXAqfY,705
|
|
3
3
|
ominfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
ominfra/cmds.py,sha256=E0AfnvEmnKntXWvmLW5L05_NeDpBET1VBXn7vV6EwBQ,2083
|
5
5
|
ominfra/configs.py,sha256=8aU1Qmbr-qjaE2iP3gAbA2SWJYMPZ-uGK007L01PoOI,1727
|
6
|
-
ominfra/pyremote.py,sha256=
|
6
|
+
ominfra/pyremote.py,sha256=vIEUncFgYvcFj3aK0dvJkRuAuaaRyqXk7c8rl2WPOR4,12599
|
7
7
|
ominfra/ssh.py,sha256=jQpc4WvkMckIfk4vILda8zFaeharRqc_6wxW50b0OjQ,5431
|
8
8
|
ominfra/threadworkers.py,sha256=oX4ubZn7h932saXpRIJu2MNhBExgGGMuGhdXarZxLJw,4948
|
9
9
|
ominfra/clouds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -57,14 +57,14 @@ ominfra/manage/deploy/poly/site.py,sha256=QJwDDJoVm2-kxi4bxIrp-mn4y2qDLuW3CAUax3
|
|
57
57
|
ominfra/manage/deploy/poly/supervisor.py,sha256=zkl6VQBcAZaMAhyR9DbbbqULcgFCDZoe9S_vP-mMFQ8,2289
|
58
58
|
ominfra/manage/deploy/poly/venv.py,sha256=BoipDEa4NTeodjf3L57KJfq9eGKLagFNKwD8pS4yrzA,1552
|
59
59
|
ominfra/manage/new/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
60
|
-
ominfra/manage/new/_manage.py,sha256=
|
61
|
-
ominfra/manage/new/main.py,sha256=
|
60
|
+
ominfra/manage/new/_manage.py,sha256=4dunrnkHpCn-c0Qtf2mxr5ocZ2_InZf7oWSaEWrbICw,43797
|
61
|
+
ominfra/manage/new/main.py,sha256=m2faeXJbyDDR-smXOQKNIgRorsWYtOXYJOlL_q_5s34,5094
|
62
62
|
ominfra/manage/new/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
63
63
|
ominfra/manage/new/commands/base.py,sha256=TTrHL213jf-ClVqToiNHuxQey1Yf6052E8u3E9hAf7Q,574
|
64
64
|
ominfra/manage/new/commands/subprocess.py,sha256=GpbD-cTorgCRg203lCl81HAh-NBYA6ObKa5ZP2ss9rg,1884
|
65
65
|
ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
66
|
ominfra/scripts/journald2aws.py,sha256=kCyeyCo53GRoCKAdVAe0aGkgmINxi8IBcUfRXphACek,131618
|
67
|
-
ominfra/scripts/supervisor.py,sha256=
|
67
|
+
ominfra/scripts/supervisor.py,sha256=3rhnR5gT3MxqFW9ew5ePYioTDLvEcM2nlYmvbGBCvzI,245884
|
68
68
|
ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
|
69
69
|
ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
70
70
|
ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
|
@@ -82,7 +82,7 @@ ominfra/supervisor/main.py,sha256=oqaWOcnHJgaxNhjyphPgjaNjHPjDcx7kzYMjtZpwSxE,42
|
|
82
82
|
ominfra/supervisor/pipes.py,sha256=2ZihNTnRNjnIPOtPbm3_pyqO15f7BNs7WnNtO5V8ahM,2231
|
83
83
|
ominfra/supervisor/privileges.py,sha256=kaRTHI7XjqzxEWCeHp3_0J0Vc4gSPugRbXEwxuw6MYE,2054
|
84
84
|
ominfra/supervisor/process.py,sha256=UaubVxsxVqDnbuWVpTH0DTGbJGLO0vGJ9mNcvy2kCXM,217
|
85
|
-
ominfra/supervisor/processimpl.py,sha256=
|
85
|
+
ominfra/supervisor/processimpl.py,sha256=eLpzoxwmXG7LoT_noFncbGGlr28Sjynz3_xYyF8gFUs,18735
|
86
86
|
ominfra/supervisor/setup.py,sha256=7HwwwI-WT_Z0WjZ9_l5Orr4K298nKKhQ1f_ZgGsi9TU,622
|
87
87
|
ominfra/supervisor/setupimpl.py,sha256=88h3oYsdJ0LAo7sZZZGRQti14oQay3b-0Vd_h3Cl108,9638
|
88
88
|
ominfra/supervisor/signals.py,sha256=jY52naUifcAjd6nICTP1ZW3IQSPsHB4cvbsJo8_QV_U,2196
|
@@ -106,9 +106,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
|
|
106
106
|
ominfra/tailscale/cli.py,sha256=DSGp4hn5xwOW-l_u_InKlSF6kIobxtUtVssf_73STs0,3567
|
107
107
|
ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
108
108
|
ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
|
109
|
-
ominfra-0.0.0.
|
110
|
-
ominfra-0.0.0.
|
111
|
-
ominfra-0.0.0.
|
112
|
-
ominfra-0.0.0.
|
113
|
-
ominfra-0.0.0.
|
114
|
-
ominfra-0.0.0.
|
109
|
+
ominfra-0.0.0.dev138.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
110
|
+
ominfra-0.0.0.dev138.dist-info/METADATA,sha256=eyC6k2kjxqRdu8PLufNmlTvtZOsyBCvxnppRs00qx7w,731
|
111
|
+
ominfra-0.0.0.dev138.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
112
|
+
ominfra-0.0.0.dev138.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
113
|
+
ominfra-0.0.0.dev138.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
114
|
+
ominfra-0.0.0.dev138.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|