From 699db117527555cbb7f37f97aa163bc6cfc21af7 Mon Sep 17 00:00:00 2001 From: Apoorv Vyavahare Date: Sat, 2 Oct 2021 23:29:19 +0530 Subject: [PATCH] Update v1.4.2 --- README.md | 2 ++ app.json | 10 ++++++++++ assets/configs/5-selfping.conf | 5 +++++ assets/scripts/self-ping.py | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100755 assets/configs/5-selfping.conf create mode 100755 assets/scripts/self-ping.py diff --git a/README.md b/README.md index 35ded0a..8cda592 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ | DISPLAY | Display Server Port | | PORT | NoVNC HTTP Port | | NGROK_AUTH_TOKEN | Ngrok Token | +| NO_SLEEP | Prevent Heroku app from sleeping, disabled by default | +| APP_NAME | Name of Heroku app | ## **Installation :** * Heroku Users : diff --git a/app.json b/app.json index f34fe15..91708db 100644 --- a/app.json +++ b/app.json @@ -19,6 +19,16 @@ "description": "VNC Server Resolution in WxH, 720p is preferrable.", "value" : "1280x720", "required" : true + }, + "NO_SLEEP" : { + "description": "Prevent app from sleeping, 1=on, 0=off", + "value" : "0", + "required" : true + }, + "APP_NAME" : { + "description": "Name of the app, same as mentioned above.", + "value" : "", + "required" : true } } } diff --git a/assets/configs/5-selfping.conf b/assets/configs/5-selfping.conf new file mode 100755 index 0000000..e84636b --- /dev/null +++ b/assets/configs/5-selfping.conf @@ -0,0 +1,5 @@ +[program:self-ping] +command=python3 /app/.vubuntu/assets/scripts/self-ping.py +stderr_logfile=/var/log/selfping.err.log +stdout_logfile=/var/log/selfping.out.log +priority=995 diff --git a/assets/scripts/self-ping.py b/assets/scripts/self-ping.py new file mode 100755 index 0000000..ac94a7b --- /dev/null +++ b/assets/scripts/self-ping.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +import os +from time import sleep +if __name__ == "__main__": + if os.getenv("NO_SLEEP") == "1": + if "APP_NAME" not in os.environ: + print("APP_NAME unset, terminating...") + exit() + app_name = os.getenv("APP_NAME") + while True: + try: + os.system(f"curl https://{app_name}.herokuapp.com") + except: + print("Ping failed, retrying...") + try: + os.system(f"curl -s https://{app_name}.herokuapp.com") + except: + print("Cannot ping app, terminating...") + sleep(25*60)