From c5bd4086fa5d538523835c541cd732fa765f6048 Mon Sep 17 00:00:00 2001 From: Yurko <39072689+YurkoWasHere@users.noreply.github.com> Date: Wed, 21 Apr 2021 19:10:18 -0400 Subject: [PATCH 1/5] Moved to config file model --- controller.py | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/controller.py b/controller.py index 0711a1e..15792ec 100755 --- a/controller.py +++ b/controller.py @@ -131,14 +131,44 @@ from xml.etree import ElementTree import psycopg2 -conn_auth = psycopg2.connect("dbname=greenlight_production user=postgres password=PASSWORD host=localhost") -DAEMON=False -BBB_URL = "https://bbb.example.com/bigbluebutton/" -BBB_SECRET = "BBB_SECRET" -BBB_RTMP_PATH = 'rtmp://192.168.178.23:1935/live/' -BBB_WEB_STREAM = 'https://bbb.example.com/streams/' -BBB_RES = '1920x1080' +with open("config.json") as json_config_file: + config = json.load(json_config_file) + +if "postgresql" in config: + if "db" in config["postgresql"] and "user" in config["postgresql"] and "password" in config["postgresql"]: + POSTGRESDB = config["postgresql"]["db"] + POSTGRESUSER = config["postgresql"]["user"] + POSTGRESPASS = config["postgresql"]["password"] + else: + print('Missing postgresql config') + sys.exit(1) + if "port" in config["postgresql"]: + POSTGRESPORT = config["postgresql"]["port"] + else: + POSTGRESPORT = 5433 + +conn_auth = psycopg2.connect("dbname=" + POSTGRESDB + " user=" + POSTGRESUSER + " password=" + POSTGRESPASS + " host=localhost port=" + POSTGRESPORT) + +DAEMON = False +BBB_URL = "" +BBB_SECRET = "" +BBB_RTMP_PATH = "" +BBB_WEB_STREAM = "" +BBB_RES = "1920x1080" + +if "daemon" in config: + DAEMON = config["daemon"] +if "bbb_url" in config: + BBB_URL = config["bbb_url"] +if "bbb_secret" in config: + BBB_SECRET = config["bbb_secret"] +if "rtmp_path" in config: + BBB_RTMP_PATH = config["rtmp_path"] +if "web_stream" in config: + BBB_WEB_STREAM = config["web_stream"] +if "bbb_res" in config: + BBB_RES = config['bbb_res'] client = docker.from_env() From b778dff9b55593342dca29ffea6d33fa926e0958 Mon Sep 17 00:00:00 2001 From: Yurko <39072689+YurkoWasHere@users.noreply.github.com> Date: Wed, 21 Apr 2021 19:18:15 -0400 Subject: [PATCH 2/5] Add config file --- config.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..8dfd966 --- /dev/null +++ b/config.json @@ -0,0 +1,15 @@ +{ + "daemon": true, + "postgresql": { + "db": "greenlight_production", + "user": "postgres", + "password": "PASSWORD", + "host": "localhost", + "port": "5433" + }, + "bbb_url": "https://bbb.example.com/bigbluebutton/", + "bbb_secret": "BBB_SECRET", + "rtmp_path": "rtmp://192.168.178.23:1935/live/", + "web_stream": "https://bbb.example.com/streams/", + "bbb_res": "1920x1080" +} From 46fedd85e2936c75acb1f6d838ebbaa449521b4a Mon Sep 17 00:00:00 2001 From: Yurko <39072689+YurkoWasHere@users.noreply.github.com> Date: Wed, 21 Apr 2021 19:19:34 -0400 Subject: [PATCH 3/5] added host --- controller.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controller.py b/controller.py index 15792ec..1e44548 100755 --- a/controller.py +++ b/controller.py @@ -135,6 +135,8 @@ with open("config.json") as json_config_file: config = json.load(json_config_file) +POSTGRESHOST = "localhost" +POSTGRESPORT = 5433 if "postgresql" in config: if "db" in config["postgresql"] and "user" in config["postgresql"] and "password" in config["postgresql"]: POSTGRESDB = config["postgresql"]["db"] @@ -145,10 +147,10 @@ sys.exit(1) if "port" in config["postgresql"]: POSTGRESPORT = config["postgresql"]["port"] - else: - POSTGRESPORT = 5433 + if "host" in config["postgresql"]: + POSTGRESHOST = config["postgresql"]["host"] -conn_auth = psycopg2.connect("dbname=" + POSTGRESDB + " user=" + POSTGRESUSER + " password=" + POSTGRESPASS + " host=localhost port=" + POSTGRESPORT) +conn_auth = psycopg2.connect("dbname=" + POSTGRESDB + " user=" + POSTGRESUSER + " password=" + POSTGRESPASS + " host=" + POSTGRESHOST + " port=" + POSTGRESPORT) DAEMON = False BBB_URL = "" From f6445de8418756842968695382bd1d222d779215 Mon Sep 17 00:00:00 2001 From: Yurko <39072689+YurkoWasHere@users.noreply.github.com> Date: Wed, 21 Apr 2021 19:31:40 -0400 Subject: [PATCH 4/5] update content of config file --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2782cb0..ecc1acd 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,18 @@ Streaming is supported with a local rtmp instance on nginx, producing HLS, which # Configuration overview -## controller.py -- Change the password in the psql connect string -- `BBB_URL` = Your BBB server or loadbalancer endpoint -- `BBB_SECRET` = Your BBB secret -- `BBB_RTMP_PATH` = `'rtmp://192.168.178.23:1935/live/'`; The IP and port on which nginx listens for rtmp connections; Firewall from the internet -- `BBB_WEB_STREAM` = `'https://bbb.example.com/streams/'`; The base-URL of your streams. Individual streams will look like `https://bbb.example.com/streams/xyz-123-zyx-412/`, depending on the room's path. -- `BBB_RES` = Resolution for the stream, e.g., `'1920x1080'`; The higher the resolution, the higher the load on the machine. +## config.json +- `daemon` = True/False - If using crontab model of execution or systemd +- `bbb_url` = Your BBB server or loadbalancer endpoint +- `bbb_secret` = Your BBB secret +- `rtmp_path` = `'rtmp://192.168.178.23:1935/live/'`; The IP and port on which nginx listens for rtmp connections; Firewall from the internet +- `web_stream` = `'https://bbb.example.com/streams/'`; The base-URL of your streams. Individual streams will look like `https://bbb.example.com/streams/xyz-123-zyx-412/`, depending on the room's path. +- `bbb_res` = Resolution for the stream, e.g., `'1920x1080'`; The higher the resolution, the higher the load on the machine. +- `postgresql` = configure postgresql + - `user` = postgresql username + - `password` = postgresql password + - `host` = postgresql host (defaults to password) + - `port` = postgresql port (defaults to 5433) ## index.html - Set URL in `src` variable according to your infrastructure (could be done better, i know) From 11fbccf6f4493d3dc5d6b0c719e3311008a99811 Mon Sep 17 00:00:00 2001 From: Yurko <39072689+YurkoWasHere@users.noreply.github.com> Date: Wed, 21 Apr 2021 19:34:05 -0400 Subject: [PATCH 5/5] Rename config.json to config.json.example --- config.json => config.json.example | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config.json => config.json.example (100%) diff --git a/config.json b/config.json.example similarity index 100% rename from config.json rename to config.json.example