-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eero
committed
Feb 8, 2024
1 parent
67d8624
commit f72d54e
Showing
13 changed files
with
106 additions
and
96 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
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,3 +1,3 @@ | ||
|
||
from . import _version | ||
__version__ = _version.get_versions()['version'] | ||
|
||
__version__ = _version.get_versions()["version"] |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import click | ||
import psutil | ||
import subprocess | ||
|
||
from delibird.server import app | ||
from delibird.log import Log, LogLevel | ||
from delibird.pm import kill_process, http_process | ||
from delibird.config import read_config | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@cli.command() | ||
@click.option( | ||
"--config", "-c", type=click.Path(exists=True), help="指定配置文件", required=True | ||
) | ||
def start(config): | ||
# init log | ||
logger = Log("delibird") | ||
|
||
# print and log | ||
logger.echo("Starting...") | ||
click.echo("Starting...") | ||
|
||
# check if the program is running | ||
if check_process("delibird"): | ||
logger.echo("The program is already running", "error") | ||
click.echo("The program is already running") | ||
return | ||
|
||
if not config: | ||
click.echo("没有配置文件") | ||
return | ||
|
||
# 从配置文件中读取 server 配置, host 和 port | ||
config_info = read_config(config) | ||
|
||
host = config_info.get("server", {}).get("host") | ||
port = config_info.get("server", {}).get("port") | ||
|
||
# check if host or port is null | ||
if not host or not port: | ||
logger.echo("host or port is null", "error") | ||
click.echo("host or port is null") | ||
return | ||
|
||
# Start the http server | ||
http_process(config, host, port) | ||
|
||
# Print and log | ||
logger.echo("Started") | ||
click.echo("Started") | ||
|
||
|
||
@cli.command() | ||
def stop(): | ||
# get logger | ||
logger = Log("delibird") | ||
|
||
# print and log | ||
logger.echo("Stopping...") | ||
click.echo("Stopping...") | ||
|
||
# kill the process | ||
kill_process() | ||
|
||
# log and close | ||
logger.echo("Stopped") | ||
click.echo("Stopped") | ||
|
||
|
||
def check_process(process_name): | ||
result = subprocess.run( | ||
["pgrep", "-f", process_name], capture_output=True, text=True | ||
) | ||
|
||
# 如果pgrep命令的输出不是空的,则有匹配的进程正在运行 | ||
return bool(result.stdout.strip()) |
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
This file was deleted.
Oops, something went wrong.
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,4 +1,4 @@ | ||
from llmproxy.mock.send import send_mock | ||
from delibird.mock.send import send_mock | ||
|
||
|
||
__all__ = ["send_mock"] |
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
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,4 +1,4 @@ | ||
from llmproxy.router.spark import send as spark_send | ||
from llmproxy.router.qwen import send as qwen_send | ||
from delibird.router.spark import send as spark_send | ||
from delibird.router.qwen import send as qwen_send | ||
|
||
__all__ = ["spark_send", "qwen_send"] |
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
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
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
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
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,4 +1,4 @@ | ||
from llmproxy.config import read_config | ||
from delibird.config import read_config | ||
|
||
|
||
def test_config(): | ||
|