diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d27878d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,15 @@ +name: Deploy to Fly +on: + push: + branches: + - master +jobs: + deploy: + name: Deploy proxy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..458b4ae --- /dev/null +++ b/fly.toml @@ -0,0 +1,22 @@ +app = "bilifeedbot" +primary_region = "nrt" +swap_size_mb = 1024 + +[build] + +[http_service] + internal_port = 9000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ["app"] + [http_service.concurrency] + type = "connections" + soft_limit = 50 + hard_limit = 100 + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 256 \ No newline at end of file diff --git a/main.py b/main.py index d923d12..596b67a 100644 --- a/main.py +++ b/main.py @@ -145,7 +145,7 @@ async def get_media( if response.status_code != 200: raise NetworkError(f"媒体文件获取错误: {response.status_code} {url}->{f.url}") mediatype = response.headers.get("content-type").split("/") - if mediatype[0] in ["video", "audio"]: + if mediatype[0] in ["video", "audio", "application"]: if not os.path.exists(".tmp"): os.mkdir(".tmp") filename = f"{time.time()}.{mediatype[1]}" @@ -696,6 +696,7 @@ def add_handler(application: Application): port=int(os.environ.get("PORT", 9000)), url_path=TOKEN, webhook_url=f'{os.environ.get("DOMAIN")}{TOKEN}', + max_connections=100, ) else: application.run_polling()