mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 16:14:16 +00:00
fix: run the module when the docsgpt command is not on PATH
Refusing to write the service units when `docsgpt` is not on PATH was wrong. A package installed in a virtualenv is runnable whether or not its console script is on PATH, and CI runs pytest as `python -m pytest`, where argv[0] is a module file: the refusal failed thirteen native tests there. The launcher now prefers the command on PATH, resolved to an absolute path since PATH can hold relative entries, then an argv[0] that can be executed, and otherwise this interpreter with `-m docsgpt`, which works wherever the package is importable. `python -m docsgpt` became an entrypoint of its own and has a test that runs it.
This commit is contained in:
1 parent
f9f52e99f0
commit
a96734da07
5 files changed
+53
-20
No files matched your search
@@ -204,20 +204,23 @@ def services_for_platform(platform: str = sys.platform):
|
||||
)
|
||||
|
||||
|
||||
def units_for(stack_directory: Path, executable: str, port: int, home: Path) -> list[Unit]:
|
||||
"""The API and worker services for a native install in ``stack_directory``."""
|
||||
def units_for(stack_directory: Path, launcher: list[str], port: int, home: Path) -> list[Unit]:
|
||||
"""The API and worker services for a native install in ``stack_directory``.
|
||||
|
||||
``launcher`` is how DocsGPT is started: the ``docsgpt`` command, or an interpreter and ``-m``.
|
||||
"""
|
||||
environment = {"DOCSGPT_HOME": str(home)}
|
||||
return [
|
||||
Unit(
|
||||
name=API_SERVICE,
|
||||
arguments=[executable, "api", "--host", "127.0.0.1", "--port", str(port)],
|
||||
arguments=[*launcher, "api", "--host", "127.0.0.1", "--port", str(port)],
|
||||
environment=dict(environment),
|
||||
working_directory=str(stack_directory),
|
||||
log_file=str(stack_directory / "logs" / "api.log"),
|
||||
),
|
||||
Unit(
|
||||
name=WORKER_SERVICE,
|
||||
arguments=[executable, "worker"],
|
||||
arguments=[*launcher, "worker"],
|
||||
environment=dict(environment),
|
||||
working_directory=str(stack_directory),
|
||||
log_file=str(stack_directory / "logs" / "worker.log"),
|
||||
|
||||
Reference in new issue
Block a user