Update entrypoint.sh
Browse files- entrypoint.sh +8 -46
entrypoint.sh
CHANGED
|
@@ -1,52 +1,14 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
-
set -e
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
app = Flask(__name__)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 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 |
-
|
| 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 |
-
# Run Flask in background as non-root user
|
| 35 |
-
nohup python3 /runner/app.py > flask.log 2>&1 &
|
| 36 |
-
|
| 37 |
-
# ----- 2. Register GitHub runner -----
|
| 38 |
-
REG_TOKEN=$(curl -s -X POST \
|
| 39 |
-
-H "Authorization: token ${MY_PAT}" \
|
| 40 |
-
https://api.github.com/repos/${GH_OWNER}/${GH_REPO}/actions/runners/registration-token \
|
| 41 |
-
| jq -r .token)
|
| 42 |
-
|
| 43 |
-
./config.sh \
|
| 44 |
-
--url https://github.com/${GH_OWNER}/${GH_REPO} \
|
| 45 |
-
--token $REG_TOKEN \
|
| 46 |
-
--name hf-runner \
|
| 47 |
-
--labels self-hosted,linux \
|
| 48 |
-
--unattended \
|
| 49 |
-
--replace
|
| 50 |
-
|
| 51 |
-
# ----- 3. Run GitHub runner in foreground -----
|
| 52 |
./run.sh
|
|
|
|
| 1 |
#!/bin/bash
|
|
|
|
| 2 |
|
| 3 |
+
# GitHub API se naya registration token mangwana
|
| 4 |
+
REG_TOKEN=$(curl -X POST -H "Authorization: token ${MY_PAT}" \
|
| 5 |
+
-H "Accept: application/vnd.github+json" \
|
| 6 |
+
https://api.github.com/repos/${GH_OWNER}/${GH_REPO}/actions/runners/registration-token | jq -r .token)
|
| 7 |
|
| 8 |
+
cd /home/runner/actions-runner
|
|
|
|
| 9 |
|
| 10 |
+
# Runner ko register karna
|
| 11 |
+
./config.sh --url https://github.com/${GH_OWNER}/${GH_REPO} --token ${REG_TOKEN} --name "HF-Runner-$(hostname)" --unattended --replace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Runner ko start karna
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
./run.sh
|