mirror of
https://github.com/snowykami/server-status-client.git
synced 2025-12-17 18:16:42 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 803f742d85 | |||
| 2e0c8ff194 | |||
| af970a77ed | |||
| a579c76002 | |||
| 66d0782106 | |||
| 851242ce51 | |||
| 703fe75a76 | |||
| d24926daeb | |||
| 80ee613746 | |||
| 851d1b0b7f | |||
| f12858a876 | |||
| a0c84037e8 | |||
| 25e137b6db | |||
| c9d6265b9c | |||
| 95667b454e | |||
| cd548f595e |
49
.github/workflows/nuitka-compile.yml
vendored
Normal file
49
.github/workflows/nuitka-compile.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
arch: [amd64, arm64, arm, 386]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Check-out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
|
||||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||
cache: 'pip'
|
||||
cache-dependency-path: |
|
||||
**/requirements*.txt
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
pip install pdm
|
||||
pdm install --no-lock
|
||||
|
||||
- name: Build Executable
|
||||
uses: Nuitka/Nuitka-Action@main
|
||||
with:
|
||||
nuitka-version: main
|
||||
script-name: server_status.__main__
|
||||
onefile: true
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ runner.os }} Build
|
||||
path: |
|
||||
build/*.exe
|
||||
build/*.bin
|
||||
build/*.app/**/*
|
||||
21
.github/workflows/pypi-publish.yml
vendored
Normal file
21
.github/workflows/pypi-publish.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
pypi-publish:
|
||||
name: upload release to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: pdm-project/setup-pdm@v3
|
||||
|
||||
- name: Publish package distributions to PyPI
|
||||
run: pdm publish
|
||||
18
README.md
18
README.md
@@ -32,16 +32,16 @@ _✨ 服务器状态 - 客户端 ✨_
|
||||
Debian系请使用pipx安装
|
||||
|
||||
```bash
|
||||
sudo apt install python3-pipx
|
||||
pipx install server-status
|
||||
sudo apt install pipx
|
||||
sudo pipx install server-status
|
||||
```
|
||||
|
||||
## 🎉 使用
|
||||
|
||||
### 命令
|
||||
|
||||
- `server_status <server> <token> <id> run` - 运行客户端
|
||||
- `server_status <server> <token> <id> rm` - 从服务端移除主机
|
||||
- `server-status <server> <token> <id> run` - 运行客户端
|
||||
- `server-status <server> <token> <id> rm` - 从服务端移除主机
|
||||
|
||||
#### 可选项
|
||||
- `-n|--name` - 设置主机名称
|
||||
@@ -60,6 +60,8 @@ server_status https://status.liteyuki.icu 114514 myhost run -n "MyHost" --labels
|
||||
### 开机启动
|
||||
执行以下命令
|
||||
```shell
|
||||
sudo pipx ensurepath # 确保pipx路径在环境变量下
|
||||
|
||||
sudo touch /etc/systemd/system/server-status-client.service
|
||||
|
||||
sudo bash -c 'cat <<EOF > /etc/systemd/system/server-status-client.service
|
||||
@@ -69,7 +71,7 @@ After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=sudo server_status <server> <token> <id> run # 请替换为实际参数
|
||||
ExecStart=server-status <server> <token> <id> run # 请替换为实际参数
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
@@ -79,4 +81,8 @@ EOF'
|
||||
|
||||
sudo systemctl enable server-status-client
|
||||
sudo systemctl start server-status-client
|
||||
```
|
||||
```
|
||||
|
||||
### 服务端
|
||||
|
||||
请在中心服务器上部署 [server-status-server](https://github.com/snowykami/server-status-server)
|
||||
@@ -1,23 +1,30 @@
|
||||
[project]
|
||||
name = "server-status-cv-py"
|
||||
version = "0.1.0"
|
||||
name = "server-status"
|
||||
dynamic = ["version"]
|
||||
description = "Server status client"
|
||||
authors = [
|
||||
{name = "snowykami", email = "snowykami@outlook.com"},
|
||||
{ name = "snowykami", email = "snowykami@outlook.com" },
|
||||
]
|
||||
dependencies = [
|
||||
"requests>=2.32.3",
|
||||
"psutil>=6.0.0",
|
||||
"arclet-alconna>=1.8.30",
|
||||
]
|
||||
requires-python = ">=3.11"
|
||||
requires-python = ">=3.10"
|
||||
readme = "README.md"
|
||||
license = {text = "MIT"}
|
||||
license = { text = "MIT" }
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-backend"]
|
||||
build-backend = "pdm.backend"
|
||||
|
||||
[project.scripts]
|
||||
server-status = "server_status.__main__:main"
|
||||
|
||||
[tool.pdm]
|
||||
distribution = true
|
||||
|
||||
[tool.pdm.version]
|
||||
source = "scm"
|
||||
tag_filter = "v*"
|
||||
tag_regex = '^v(?:\D*)?(?P<version>([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$)$'
|
||||
@@ -1,10 +1,10 @@
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from server_status.api import *
|
||||
from server_status.cmd_parser import server_status_alc
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
raw_msg = "server_status " + " ".join(sys.argv[1:])
|
||||
arp = server_status_alc.parse(raw_msg)
|
||||
|
||||
@@ -35,3 +35,7 @@ if __name__ == "__main__":
|
||||
|
||||
else:
|
||||
log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -106,17 +106,15 @@ class Api:
|
||||
"""
|
||||
self.headers.update(self.format(headers))
|
||||
|
||||
def format(self, obj: str | tuple[str, ...] | dict[str, Any]):
|
||||
def format(self, obj: str | list[str] | dict[str, Any]) -> str | list[str] | dict[str, Any]:
|
||||
if isinstance(obj, str):
|
||||
obj = obj.format(**self.variables)
|
||||
elif isinstance(obj, dict):
|
||||
for key in obj:
|
||||
obj[key] = self.format(obj[key])
|
||||
elif isinstance(obj, (list, tuple)):
|
||||
elif isinstance(obj, list):
|
||||
for i in range(len(obj)):
|
||||
obj[i] = self.format(obj[i])
|
||||
else:
|
||||
pass
|
||||
return obj
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user