-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Enhance daemon functionality and options 🚀
- Added `--wait` option to the `ready` command in `cli.py` - Refined PID file creation logic in `pidfile.py` - Introduced `portfile.py` for managing communication ports - Restructured `Daemon` and `Worker` classes to use ports - Improved health verification logic in `Master` and `Worker` - Removed deprecated `assert_peers_healthy` functionality - Updated dependencies in `pyproject.toml` to latest versions Files changed: - `cli.py` - `daemon.py` - `daemonize.py` - `ensure_pressed.py` - `healthy.py` (deleted) - `master.py` - `pidfile.py` - `portfile.py` (new) - `possess.py` - `tcp.py` - `worker.py` - `pyproject.toml` - `test_daemon.py`
- Loading branch information
Showing
13 changed files
with
97 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
from pathlib import Path | ||
|
||
from deciphon_schema import HMMFile | ||
from pidlockfile import PIDLockFile | ||
|
||
__all__ = ["create_pidfile"] | ||
|
||
|
||
def create_pidfile(file: Path, timeout=5): | ||
return PIDLockFile(f"{str(file.absolute())}.pid", timeout=timeout) | ||
def create_pidfile(hmmfile: HMMFile, timeout=5): | ||
return PIDLockFile(f"{str(hmmfile.path.absolute())}.pid", timeout=timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
|
||
from pidlockfile import PIDLockFile | ||
|
||
__all__ = ["create_portfile", "read_portfile"] | ||
|
||
|
||
def create_portfile(pidfile: PIDLockFile, cport: int, wport: int): | ||
portfile = _portfile(pidfile) | ||
with open(portfile, "w") as f: | ||
f.write(f"{cport} {wport}\n") | ||
return portfile | ||
|
||
|
||
def read_portfile(pidfile: PIDLockFile): | ||
portfile = _portfile(pidfile) | ||
with open(portfile, "r") as f: | ||
cport, wport = f.readline().strip().split(" ") | ||
return int(cport), int(wport) | ||
|
||
|
||
def _portfile(pidfile: PIDLockFile): | ||
return f"{str(Path(pidfile.path).absolute())}.port" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from psutil import Process | ||
import socket | ||
|
||
__all__ = ["tcp_connections"] | ||
__all__ = ["can_connect"] | ||
|
||
|
||
def tcp_connections(x: Process): | ||
# psutil bug: https://github.com/giampaolo/psutil/issues/2116 | ||
with open("/dev/null", "wb"): | ||
connections = x.net_connections(kind="tcp") | ||
return connections | ||
def can_connect(host: str, port: int): | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.connect((host, port)) | ||
return True | ||
except ConnectionRefusedError: | ||
return False |
Oops, something went wrong.