Skip to content

Commit 54d79e8

Browse files
committed
Mess with Services() (unfinished)
1 parent 2f11e94 commit 54d79e8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

bolt-dev/bolt/dev/cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def cli(ctx, port):
4040
sys.exit(returncode)
4141

4242

43+
@cli.command()
44+
def services():
45+
"""Start additional services defined in pyproject.toml"""
46+
Services().run()
47+
48+
4349
class Dev:
4450
def __init__(self, *, port):
4551
self.manager = HonchoManager()

bolt-dev/bolt/dev/services.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import subprocess
3+
import time
24
from pathlib import Path
35

46
import click
@@ -31,11 +33,7 @@ def get_services(root):
3133
def __init__(self):
3234
self.manager = HonchoManager()
3335

34-
def __enter__(self):
35-
if Pid().exists():
36-
click.secho("Services already running in `bolt dev` command", fg="yellow")
37-
return
38-
36+
def run(self):
3937
services = self.get_services(APP_PATH.parent)
4038
for name, data in services.items():
4139
env = {
@@ -47,5 +45,16 @@ def __enter__(self):
4745

4846
self.manager.loop()
4947

48+
def __enter__(self):
49+
if Pid().exists():
50+
click.secho("Services already running in `bolt dev` command", fg="yellow")
51+
return
52+
53+
print("Starting `bolt dev services`")
54+
self.subprocess = subprocess.Popen(
55+
["bolt", "dev", "services"], cwd=APP_PATH.parent
56+
)
57+
time.sleep(0.5)
58+
5059
def __exit__(self, *args):
51-
self.manager.terminate()
60+
self.subprocess.terminate()

0 commit comments

Comments
 (0)