1717from uuid import uuid4
1818
1919from .syntax import ScriptSyntax , get as syntax_from_name
20+ from .util import process
2021from .util .message import Args , decode , encode
2122
2223
@@ -43,9 +44,12 @@ class Service:
4344
4445 _service_count : int = 0
4546
46- def __init__ (self , cwd : str | Path , args : list [str ]) -> None :
47+ def __init__ (
48+ self , cwd : str | Path , env_vars : dict [str , str ] | None = None , * args : str
49+ ) -> None :
4750 self ._cwd : Path = Path (cwd )
48- self ._args : list [str ] = args [:]
51+ self ._env_vars : dict [str , str ] = env_vars .copy () if env_vars is not None else {}
52+ self ._args : list [str ] = list (args )
4953 self ._tasks : dict [str , "Task" ] = {}
5054 self ._service_id : int = Service ._service_count
5155 Service ._service_count += 1
@@ -54,6 +58,7 @@ def __init__(self, cwd: str | Path, args: list[str]) -> None:
5458 self ._stderr_thread : threading .Thread | None = None
5559 self ._monitor_thread : threading .Thread | None = None
5660 self ._debug_callback : Callable [[Any ], Any ] | None = None
61+ self ._syntax : ScriptSyntax | None = None
5762
5863 def debug (self , debug_callback : Callable [[Any ], Any ]) -> None :
5964 """
@@ -80,13 +85,8 @@ def start(self) -> None:
8085 return
8186
8287 prefix = f"Appose-Service-{ self ._service_id } "
83- self ._process = subprocess .Popen (
84- self ._args ,
85- stdin = subprocess .PIPE ,
86- stdout = subprocess .PIPE ,
87- cwd = self ._cwd ,
88- text = True ,
89- )
88+
89+ self ._process = process .builder (self ._cwd , self ._env_vars , * self ._args )
9090 self ._stdout_thread = threading .Thread (
9191 target = self ._stdout_loop , name = f"{ prefix } -Stdout"
9292 )
0 commit comments