kamiwork commited on
Commit
d347345
·
verified ·
1 Parent(s): 84cb4dc

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +34 -3
entrypoint.sh CHANGED
@@ -1,13 +1,44 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- # ----- Register GitHub Runner -----
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  REG_TOKEN=$(curl -s -X POST \
6
  -H "Authorization: token ${MY_PAT}" \
7
  https://api.github.com/repos/${GH_OWNER}/${GH_REPO}/actions/runners/registration-token \
8
  | jq -r .token)
9
 
10
- # Configure runner
11
  ./config.sh \
12
  --url https://github.com/${GH_OWNER}/${GH_REPO} \
13
  --token $REG_TOKEN \
@@ -16,5 +47,5 @@ REG_TOKEN=$(curl -s -X POST \
16
  --unattended \
17
  --replace
18
 
19
- # ----- Run the runner -----
20
  ./run.sh
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # ----- 1. Start a simple Flask web app on port 7860 -----
5
+ cat <<EOF > /runner/app.py
6
+ from flask import Flask, jsonify, render_template_string
7
+ import time
8
+
9
+ start_time = time.time()
10
+ app = Flask(__name__)
11
+
12
+ HTML = """
13
+ <!doctype html>
14
+ <title>GitHub Runner Status</title>
15
+ <h1>GitHub Runner on HF Space</h1>
16
+ <p>Status: <b>Running</b></p>
17
+ <p>Uptime: {{uptime}} minutes</p>
18
+ """
19
+
20
+ @app.route("/")
21
+ def index():
22
+ uptime = int((time.time() - start_time)/60)
23
+ return render_template_string(HTML, uptime=uptime)
24
+
25
+ @app.route("/status")
26
+ def status():
27
+ uptime = int((time.time() - start_time)/60)
28
+ return jsonify({"runner": "online", "uptime_minutes": uptime})
29
+
30
+ if __name__ == "__main__":
31
+ app.run(host="0.0.0.0", port=7860)
32
+ EOF
33
+
34
+ python3 /runner/app.py &
35
+
36
+ # ----- 2. Register GitHub Runner -----
37
  REG_TOKEN=$(curl -s -X POST \
38
  -H "Authorization: token ${MY_PAT}" \
39
  https://api.github.com/repos/${GH_OWNER}/${GH_REPO}/actions/runners/registration-token \
40
  | jq -r .token)
41
 
 
42
  ./config.sh \
43
  --url https://github.com/${GH_OWNER}/${GH_REPO} \
44
  --token $REG_TOKEN \
 
47
  --unattended \
48
  --replace
49
 
50
+ # ----- 3. Run the GitHub runner -----
51
  ./run.sh