-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
b7a295b
commit 7d3b1c6
Showing
3 changed files
with
42 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,5 +216,6 @@ def start(ctx): | |
|
||
cli.add_command(service) | ||
|
||
|
||
def app_start(): | ||
cli(obj={}) |
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,63 +1,76 @@ | ||
import os | ||
import sys | ||
|
||
import rich_click as click | ||
|
||
from .service_managers import select_service_manager | ||
|
||
|
||
@click.group() | ||
@click.pass_context | ||
def service(ctx): | ||
"""Manage the program as a service (executable only)""" | ||
ctx.ensure_object(dict) | ||
if os.getenv("PYAPP") is None: | ||
print("Service commands are only available in the executable version of the program") | ||
print( | ||
"Service commands are only available in the executable version of the" | ||
" program" | ||
) | ||
sys.exit(1) | ||
ctx.obj["service_manager"] = select_service_manager()(os.getenv("PYAPP")) | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def start(ctx): | ||
"""Start the service""" | ||
ctx.obj["service_manager"].start() | ||
|
||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def stop(ctx): | ||
"""Stop the service""" | ||
ctx.obj["service_manager"].stop() | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def restart(ctx): | ||
"""Restart the service""" | ||
ctx.obj["service_manager"].restart() | ||
|
||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def status(ctx): | ||
"""Get the status of the service""" | ||
ctx.obj["service_manager"].status() | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def install(ctx): | ||
"""Install the service""" | ||
ctx.obj["service_manager"].install() | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def uninstall(ctx): | ||
"""Uninstall the service""" | ||
ctx.obj["service_manager"].uninstall() | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def enable(ctx): | ||
"""Enable the service""" | ||
ctx.obj["service_manager"].enable() | ||
|
||
|
||
@service.command() | ||
@click.pass_context | ||
def disable(ctx): | ||
"""Disable the service""" | ||
ctx.obj["service_manager"].disable() | ||
|
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