configure script added, restart script added, uninstall script added, upgrade script added, config.py excluded from repository and added to .gitignore, install.py improved, generate nginx config fixed
This commit is contained in:
+10
-1
@@ -139,4 +139,13 @@ dmypy.json
|
||||
cython_debug/
|
||||
|
||||
#nginx configuration files
|
||||
*.conf
|
||||
*.conf
|
||||
|
||||
#example files
|
||||
*.example
|
||||
|
||||
#nginx conf
|
||||
nginx/
|
||||
|
||||
#config
|
||||
config.py
|
||||
@@ -1,10 +1,8 @@
|
||||
session server installation process:
|
||||
|
||||
all paths stored in config.py
|
||||
|
||||
1. install everything from "should_install" directory
|
||||
2. setup session-server config files inside "session_server_config" directory
|
||||
3. run "start_install_package.py" script with double click or run from powershell with "python" prefix
|
||||
2. setup config.py (you should create config.py, check example in config.py.example)
|
||||
3. run "install.py" script with double click or run from powershell with "python" prefix
|
||||
|
||||
if everything OK package installed
|
||||
|
||||
@@ -13,4 +11,5 @@ you can check "session-server" status with following commands: "pm2 status", "pm
|
||||
session server configuration change process:
|
||||
|
||||
1. change config files inside "session_server_config" directory
|
||||
2. run "reconfigure_package.py" script with double click or run from powershell with "python" prefix
|
||||
2. run "configure.py" script with double click or run from powershell with "python" prefix
|
||||
3. run "restart.py" script with double click or run from powershell with "python" prefix
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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'
|
||||
|
||||
# nginx config
|
||||
|
||||
server_domain = 'a2.sess.graff.tech'
|
||||
session_server_ip = "192.168.0.10"
|
||||
server_postfix = "s1"
|
||||
session_server_port = 3005
|
||||
|
||||
session_begin_port = 14000
|
||||
session_limit = 4
|
||||
@@ -0,0 +1,75 @@
|
||||
import config
|
||||
import os
|
||||
import sys
|
||||
|
||||
stdout_default = sys.stdout
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
env_file_name = config.env_file_name
|
||||
titles_file_name = config.titles_file_name
|
||||
|
||||
session_server_root_dir = deploy_path + '/pixel-streaming-session-server'
|
||||
|
||||
if not os.path.isdir(session_server_root_dir):
|
||||
print('Package not installed')
|
||||
exit()
|
||||
|
||||
# define config variables
|
||||
server_port = config.session_server_port
|
||||
server_domain = config.session_server_domain
|
||||
coordinator_url = config.coordinator_url
|
||||
database_url = config.local_database_url
|
||||
database_name = config.local_database_name
|
||||
session_begin_port = config.session_begin_port
|
||||
session_limit = config.session_limit
|
||||
webrtc_server_path = config.webrtc_server_path
|
||||
|
||||
session_server_postfix = config.session_server_postfix
|
||||
applications = config.applications
|
||||
|
||||
# generate session server .env
|
||||
|
||||
env_file_path = session_server_root_dir + '/' + env_file_name
|
||||
|
||||
output_file = open(env_file_path, 'w')
|
||||
sys.stdout = output_file
|
||||
|
||||
print('PORT=', server_port)
|
||||
print('EXTERNAL_DOMAIN=', '"' + server_domain + '/' + session_server_postfix + '/' + '"')
|
||||
print('COORDINATOR_URL=', '"' + coordinator_url + '"')
|
||||
print('DATABASE_URL=', '"' + database_url + '"')
|
||||
print('DATABASE_NAME=', '"' + database_name + '"')
|
||||
print('WEBRTC_PORT_BEGIN=', session_begin_port)
|
||||
print('SESSION_LIMIT=', session_limit)
|
||||
print('WEBRTC_SERVER_PATH=', '"' + webrtc_server_path + '"')
|
||||
|
||||
sys.stdout = stdout_default
|
||||
output_file.close()
|
||||
|
||||
# generate sesion server titles.json
|
||||
|
||||
titles_file_path = session_server_root_dir + '/' + titles_file_name
|
||||
|
||||
output_file = open(titles_file_path, 'w')
|
||||
sys.stdout = output_file
|
||||
|
||||
|
||||
app_last_index = len(applications)
|
||||
|
||||
print('[')
|
||||
|
||||
for i in range(0, app_last_index):
|
||||
print('\t{')
|
||||
print('\t\t' + '"title":"' + applications[i][0] + '",')
|
||||
print('\t\t' + '"path":"' + applications[i][1] + '"')
|
||||
if i == app_last_index - 1:
|
||||
print('\t}')
|
||||
else:
|
||||
print('\t},')
|
||||
|
||||
print(']')
|
||||
|
||||
sys.stdout = stdout_default
|
||||
output_file.close()
|
||||
|
||||
print('\nPackage configured.\n')
|
||||
@@ -1,28 +1,31 @@
|
||||
# generate nginx config
|
||||
import sys
|
||||
import config
|
||||
from pathlib import Path
|
||||
|
||||
# config
|
||||
server_domain = config.server_domain
|
||||
session_server_domain = config.session_server_domain
|
||||
session_server_ip = config.session_server_ip
|
||||
server_postfix = config.server_postfix
|
||||
session_server_postfix = config.session_server_postfix
|
||||
session_server_port = config.session_server_port
|
||||
session_begin_port = config.session_begin_port
|
||||
session_limit = config.session_limit
|
||||
nginx_dir_name = 'nginx'
|
||||
|
||||
# redirect stdout to file
|
||||
stdout_default = sys.stdout
|
||||
output_file_name = 'session-server-' + server_postfix + '.conf'
|
||||
Path(nginx_dir_name).mkdir(parents=True, exist_ok=True)
|
||||
output_file_name = nginx_dir_name+ '/' + 'session-server-' + session_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('\tserver_name ' + str(session_server_domain) + ';')
|
||||
|
||||
print('\n\t#session server location')
|
||||
print('\tlocation /' + server_postfix + '/ {')
|
||||
print('\tlocation /' + session_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;')
|
||||
@@ -34,7 +37,7 @@ 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('\tlocation /' + str(session_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';")
|
||||
@@ -47,4 +50,6 @@ print('}')
|
||||
|
||||
# undo redirect to file
|
||||
sys.stdout = stdout_default
|
||||
output_file.close()
|
||||
output_file.close()
|
||||
|
||||
print('nginx config file saved to: ' + output_file_name)
|
||||
@@ -1,15 +1,12 @@
|
||||
import config
|
||||
import headers.powershell as powershell
|
||||
import shutil
|
||||
import powershell
|
||||
import os
|
||||
|
||||
# config
|
||||
deploy_path = config.deploy_path
|
||||
git_url_session_server = config.git_url_session_server
|
||||
git_url_webrtc = config.git_url_webrtc
|
||||
|
||||
env_path = config.env_path
|
||||
titles_path = config.titles_path
|
||||
pm2_name = config.pm2_name
|
||||
|
||||
if os.path.isdir(deploy_path):
|
||||
print('Package already installed in: ', deploy_path)
|
||||
@@ -31,23 +28,16 @@ session_server_root_dir = deploy_path + '/pixel-streaming-session-server'
|
||||
powershell.run_command('npm install', session_server_root_dir)
|
||||
powershell.run_command('npm install', deploy_path + '/pixel-streaming-webrtc/WebServers/SignallingWebServer')
|
||||
|
||||
# copy session server config to destination directory
|
||||
current_directory_name = os.path.dirname(os.path.abspath(__file__))
|
||||
session_server_config_file = (current_directory_name + env_path).replace('\\', '/')
|
||||
session_server_config_destination = deploy_path + '/pixel-streaming-session-server/.env'
|
||||
shutil.copy(session_server_config_file, session_server_config_destination)
|
||||
|
||||
# copy session server titles config to destination directory
|
||||
session_server_titles_file = (current_directory_name + titles_path).replace('\\', '/')
|
||||
session_server_titles_destination = deploy_path + '/pixel-streaming-session-server/titles.json'
|
||||
shutil.copy(session_server_titles_file, session_server_titles_destination)
|
||||
# configure session server
|
||||
import configure
|
||||
|
||||
# install pm2 for application management
|
||||
powershell.run_command_no_dir('npm i -g pm2')
|
||||
|
||||
# start session server
|
||||
powershell.run_command('pm2 start app.js --no-treekill --name session-server', session_server_root_dir)
|
||||
powershell.run_command('pm2 start app.js --no-treekill --name ' + pm2_name, session_server_root_dir)
|
||||
|
||||
# add to startup
|
||||
#################################################################################################################
|
||||
|
||||
print('\nPackage successfully deployed to: ', deploy_path, '\n')
|
||||
@@ -1,33 +0,0 @@
|
||||
import config
|
||||
import lib.powershell as powershell
|
||||
import shutil
|
||||
import os
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
env_path = config.env_path
|
||||
titles_path = config.titles_path
|
||||
|
||||
session_server_root_dir = deploy_path + '/pixel-streaming-session-server'
|
||||
|
||||
if not os.path.isdir(session_server_root_dir):
|
||||
print('Package not installed')
|
||||
exit()
|
||||
|
||||
powershell.run_command('pm2 stop app.js', session_server_root_dir)
|
||||
|
||||
# copy session server config to destination directory
|
||||
current_directory_name = os.path.dirname(os.path.abspath(__file__))
|
||||
session_server_config_file = (current_directory_name + env_path).replace('\\', '/')
|
||||
session_server_config_destination = deploy_path + '/pixel-streaming-session-server/.env'
|
||||
os.remove(session_server_config_destination)
|
||||
shutil.copy(session_server_config_file, session_server_config_destination)
|
||||
|
||||
# copy session server titles config to destination directory
|
||||
session_server_titles_file = (current_directory_name + titles_path).replace('\\', '/')
|
||||
session_server_titles_destination = deploy_path + '/pixel-streaming-session-server/titles.json'
|
||||
os.remove(session_server_titles_destination)
|
||||
shutil.copy(session_server_titles_file, session_server_titles_destination)
|
||||
|
||||
powershell.run_command('pm2 restart app.js --no-treekill', session_server_root_dir)
|
||||
|
||||
print('\nPackage successfully reconfigured.\n')
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import config
|
||||
import powershell
|
||||
import os
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
pm2_name = config.pm2_name
|
||||
|
||||
if os.path.isdir(deploy_path):
|
||||
powershell.run_command_no_dir('pm2 restart ' + pm2_name + ' --no-treekill')
|
||||
powershell.run_command_no_dir('pm2 reset ' + pm2_name)
|
||||
print('\nPackage restarted\n')
|
||||
else:
|
||||
print('\nPackage not installed.\n')
|
||||
@@ -1,9 +0,0 @@
|
||||
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
|
||||
SESSION_LIMIT=7
|
||||
@@ -1,6 +0,0 @@
|
||||
[
|
||||
{
|
||||
"title":"only-dev-test-mosharov",
|
||||
"path":"D:/shared/Builds/mosharov/mosharov-stream-v1/Masharovdev.exe"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
import config
|
||||
import powershell
|
||||
import os
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
pm2_name = config.pm2_name
|
||||
|
||||
if os.path.isdir(deploy_path):
|
||||
powershell.run_command_no_dir('pm2 delete ' + pm2_name + '; rm "' + deploy_path + '" -r -force;')
|
||||
print('Package successfully uninstalled')
|
||||
else:
|
||||
print('Package not installed')
|
||||
@@ -1,11 +0,0 @@
|
||||
import config
|
||||
import headers.powershell as powershell
|
||||
import os
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
|
||||
if os.path.isdir(deploy_path):
|
||||
powershell.run_command_no_dir('pm2 delete all; rm "' + deploy_path + '" -r -force;')
|
||||
print('Package successfully removed')
|
||||
else:
|
||||
print('Package not installed')
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import config
|
||||
import powershell
|
||||
import os
|
||||
|
||||
# config
|
||||
git_url_session_server = config.git_url_session_server
|
||||
git_url_webrtc = config.git_url_webrtc
|
||||
git_url_lib = config.git_url_lib
|
||||
|
||||
deploy_path = config.deploy_path
|
||||
git_url_session_server = config.git_url_session_server
|
||||
git_url_webrtc = config.git_url_webrtc
|
||||
pm2_name = config.pm2_name
|
||||
|
||||
if not os.path.isdir(deploy_path):
|
||||
print('Package not installed')
|
||||
exit(1)
|
||||
|
||||
# clone required repositories
|
||||
powershell.run_command('git pull', deploy_path + '/pixel-streaming-session-server')
|
||||
powershell.run_command('git pull', deploy_path + '/pixel-streaming-webrtc')
|
||||
|
||||
# clone submodules
|
||||
session_server_library = deploy_path + '/pixel-streaming-session-server/lib'
|
||||
|
||||
powershell.run_command('git pull ' + git_url_lib + ' master', session_server_library)
|
||||
|
||||
# install node_modules
|
||||
session_server_root_dir = deploy_path + '/pixel-streaming-session-server'
|
||||
powershell.run_command('npm install', session_server_root_dir)
|
||||
powershell.run_command('npm install', deploy_path + '/pixel-streaming-webrtc/WebServers/SignallingWebServer')
|
||||
|
||||
# configure session server
|
||||
import configure
|
||||
import restart
|
||||
|
||||
print('\nPackage successfully upgraded.\n')
|
||||
Reference in New Issue
Block a user