.env config updated, pm2 no-treekill and name added, config.py updated, .conf added to .gitignore, generate nginx configuration added

This commit is contained in:
C
2023-02-09 15:37:13 +05:00
parent 68eebe248d
commit 036d91a630
6 changed files with 72 additions and 7 deletions
+1 -1
View File
@@ -139,4 +139,4 @@ dmypy.json
cython_debug/
#nginx configuration files
.conf
*.conf
+15 -1
View File
@@ -1,6 +1,20 @@
# location
deploy_path = 'C:/pixel-streaming'
# git
git_url_session_server = "http://212.220.216.185:3000/EgorSuv/pixel-streaming-session-server.git"
git_url_webrtc = "http://212.220.216.185:3000/EgorSuv/pixel-streaming-webrtc.git"
# session server config
env_path = '/session_server_config/.env'
titles_path = '/session_server_config/titles.json'
titles_path = '/session_server_config/titles.json'
# nginx config
server_domain = 'a1.test.sess.graff.tech'
session_server_ip = "192.168.1.115"
server_postfix = "s1"
session_server_port = 3005
session_begin_port = 14000
session_limit = 7
+50
View File
@@ -0,0 +1,50 @@
# generate nginx config
import sys
import config
# config
server_domain = config.server_domain
session_server_ip = config.session_server_ip
server_postfix = config.server_postfix
session_server_port = config.session_server_port
session_begin_port = config.session_begin_port
session_limit = config.session_limit
# redirect stdout to file
stdout_default = sys.stdout
output_file_name = 'session-server-' + server_postfix + '.conf'
output_file = open(output_file_name, 'w')
sys.stdout = output_file
# generate config
print('server {')
print('\t#session server domain')
print('\tserver_name ' + str(server_domain) + ';')
print('\n\t#session server location')
print('\tlocation /' + server_postfix + '/ {')
print('\t\tproxy_pass http://' + session_server_ip + ':' + str(session_server_port) + '/;')
print('\t\tproxy_http_version 1.1;')
print('\t\tproxy_set_header Upgrade $http_upgrade;')
print("\t\tproxy_set_header Connection 'upgrade';")
print('\t\tproxy_set_header Host $host;')
print('\t\tproxy_cache_bypass $http_upgrade;')
print('\t}\n')
print('\t#sessions location')
for i in range(0, session_limit):
print('\tlocation /' + str(server_postfix) + '/' + str(session_begin_port + i) + '/ {')
print('\t\tproxy_pass http://' + str(session_server_ip) + ':' + str(session_begin_port + i) + '/;')
print('\t\tproxy_set_header Upgrade $http_upgrade;')
print("\t\tproxy_set_header Connection 'upgrade';")
print("\t\tproxy_connect_timeout 86400s;")
print("\t\tproxy_send_timeout 86400s;")
print("\t\tproxy_read_timeout 86400s;")
print('\t}')
print('}')
# undo redirect to file
sys.stdout = stdout_default
output_file.close()
+1 -1
View File
@@ -28,6 +28,6 @@ session_server_titles_destination = deploy_path + '/pixel-streaming-session-serv
os.remove(session_server_titles_destination)
shutil.copy(session_server_titles_file, session_server_titles_destination)
powershell.run_command('pm2 restart app.js', session_server_root_dir)
powershell.run_command('pm2 restart app.js --no-treekill', session_server_root_dir)
print('\nPackage successfully reconfigured.\n')
+3 -2
View File
@@ -1,8 +1,9 @@
PORT=3005
PORT=3006
# nginx external domain
EXTERNAL_DOMAIN="a1.test.sess.graff.tech/s1/"
# coordinator url
COORDINATOR_URL="https://a1.test.coord.graff.tech"
DATABASE_URL="mongodb://127.0.0.1:27017"
DATABASE_NAME="pixel_streaming"
WEBRTC_PORT_BEGIN=14000
WEBRTC_PORT_BEGIN=14000
SESSION_LIMIT=7
+2 -2
View File
@@ -46,8 +46,8 @@ shutil.copy(session_server_titles_file, session_server_titles_destination)
powershell.run_command_no_dir('npm i -g pm2')
# start session server
powershell.run_command('pm2 start app.js', session_server_root_dir)
powershell.run_command('pm2 start app.js --no-treekill --name session-server', session_server_root_dir)
# add to startup
# add to startup
print('\nPackage successfully deployed to: ', deploy_path, '\n')