fix(deploy): legg til Procfile + main.py for Cloud Run Buildpacks entrypoint
This commit is contained in:
parent
1e5400ab3a
commit
59d9859a48
1
Procfile
Normal file
1
Procfile
Normal file
|
|
@ -0,0 +1 @@
|
|||
web: gunicorn main:app --bind 0.0.0.0:$PORT --workers 1 --threads 8 --timeout 120
|
||||
53
main.py
Normal file
53
main.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
main.py — Cloud Run entrypoint for OSVauco OPAX agent.
|
||||
Exposes a minimal Flask HTTP API that wraps agent.run().
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Ensure agents/core-logic is on the path
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "agents", "core-logic"))
|
||||
|
||||
from flask import Flask, request, jsonify
|
||||
from agent import run # agents/core-logic/agent.py
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route("/health", methods=["GET"])
|
||||
def health():
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
|
||||
@app.route("/run", methods=["POST"])
|
||||
def run_agent():
|
||||
body = request.get_json(force=True, silent=True) or {}
|
||||
message = body.get("message", "")
|
||||
user_id = body.get("user_id", "opax")
|
||||
session_id = body.get("session_id", "default")
|
||||
mode = body.get("mode", "A")
|
||||
|
||||
if not message:
|
||||
return jsonify({"error": "'message' field required"}), 400
|
||||
|
||||
try:
|
||||
response = run(
|
||||
message=message,
|
||||
user_id=user_id,
|
||||
session_id=session_id,
|
||||
mode=mode,
|
||||
)
|
||||
return jsonify({"response": response})
|
||||
except PermissionError as e:
|
||||
return jsonify({"error": str(e)}), 403
|
||||
except ValueError as e:
|
||||
return jsonify({"error": str(e)}), 400
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
port = int(os.environ.get("PORT", 8080))
|
||||
app.run(host="0.0.0.0", port=port)
|
||||
Loading…
Reference in New Issue
Block a user