Skip to content

Commit

Permalink
Added chia start daemon (#17704)
Browse files Browse the repository at this point in the history
* Added `chia start daemon`

* Added a test case

* Fixed lint issues

* Reverted changes in `services_for_groups`

* Fixed coverage issue
  • Loading branch information
ChiaMineJP committed Mar 18, 2024
1 parent 71ced4c commit 2f3fce5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions chia/_tests/util/test_service_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

from chia.util.service_groups import services_for_groups


def test_services_for_groups() -> None:
i = 0
for service in services_for_groups(["harvester"]):
assert service == "chia_harvester"
i += 1
assert i == 1

for _ in services_for_groups(["daemon"]):
# The loop should never be run
assert False # pragma: no cover
2 changes: 1 addition & 1 deletion chia/cmds/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def async_stop(root_path: Path, config: Dict[str, Any], group: tuple[str,

@click.command("stop", help="Stop services")
@click.option("-d", "--daemon", is_flag=True, type=bool, help="Stop daemon")
@click.argument("group", type=click.Choice(list(all_groups())), nargs=-1, required=True)
@click.argument("group", type=click.Choice([g for g in list(all_groups()) if g != "daemon"]), nargs=-1, required=True)
@click.pass_context
def stop_cmd(ctx: click.Context, daemon: bool, group: tuple[str, ...]) -> None:
from chia.cmds.beta_funcs import warn_if_beta_enabled
Expand Down
5 changes: 3 additions & 2 deletions chia/util/service_groups.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from typing import Generator, Iterable, KeysView
from typing import Dict, Generator, Iterable, KeysView

SERVICES_FOR_GROUP = {
SERVICES_FOR_GROUP: Dict[str, list[str]] = {
"all": [
"chia_harvester",
"chia_timelord_launcher",
Expand All @@ -13,6 +13,7 @@
"chia_data_layer",
"chia_data_layer_http",
],
"daemon": [],
# TODO: should this be `data_layer`?
"data": ["chia_wallet", "chia_data_layer"],
"data_layer_http": ["chia_data_layer_http"],
Expand Down

0 comments on commit 2f3fce5

Please sign in to comment.