From 2898bea6d25c2d52c3c1b56e55cee47f689d06c4 Mon Sep 17 00:00:00 2001 From: C Date: Mon, 13 Feb 2023 16:30:09 +0500 Subject: [PATCH] startup added to install script and config.py.example added --- .gitignore | 2 +- config.py.example | 38 ++++++++++++++++++++++++++++++++++++++ install.py | 16 +++++++++++++++- startup_script.py | 2 ++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 config.py.example create mode 100644 startup_script.py diff --git a/.gitignore b/.gitignore index b6ce030..2e95d59 100644 --- a/.gitignore +++ b/.gitignore @@ -142,7 +142,7 @@ cython_debug/ *.conf #example files -*.example +#*.example #nginx conf nginx/ diff --git a/config.py.example b/config.py.example new file mode 100644 index 0000000..5dc8f5c --- /dev/null +++ b/config.py.example @@ -0,0 +1,38 @@ +# deploy location +deploy_path = 'C:/pixel-streaming' + +# git source +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' +git_url_lib = 'http://212.220.216.185:3000/EgorSuv/pixel-streaming-lib' + +# session server config +env_file_name = '.env' +titles_file_name = 'titles.json' + +# coordinator +coordinator_url = 'https://a1.coord.graff.tech' + +# local database +local_database_url = 'mongodb://127.0.0.1:27017' +local_database_name = 'pixel_streaming' + +# nginx and session server config +session_server_domain = 'a2.sess.graff.tech' +session_server_postfix = 's2' + +session_server_ip = '192.168.0.11' +session_server_port = 3005 + +session_begin_port = 14000 +session_limit = 5 + +webrtc_server_path = '../pixel-streaming-webrtc/WebServers/SignallingWebServer/cirrus.js' + +#app format ['title', 'path'] +applications = [ + ['mosharov', 'D:/shared/Builds/mosharov/mosharov-stream-v1/Masharovdev.exe'], + ['ivazowsky', 'D:/shared/Builds/mosharov/mosharov-stream-v1/Masharovdev.exe'] +] + +pm2_name = 'session-server' \ No newline at end of file diff --git a/install.py b/install.py index 69cba0d..4e053b9 100644 --- a/install.py +++ b/install.py @@ -1,6 +1,18 @@ import config import powershell import os +import getpass +import pathlib + +# startup function +USER_NAME = getpass.getuser() + +def add_to_startup(file_path="", file_name=''): + if file_path == "": + file_path = os.path.dirname(os.path.realpath(__file__)) + bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % USER_NAME + with open(bat_path + '\\' + file_name + ".bat", "w+") as bat_file: + bat_file.write(r'python "%s" %%*' % file_path) # config deploy_path = config.deploy_path @@ -36,8 +48,10 @@ powershell.run_command_no_dir('npm i -g pm2') # start session server powershell.run_command('pm2 start app.js --no-treekill --name ' + pm2_name, session_server_root_dir) +powershell.run_command_no_dir('pm2 save') # add to startup -################################################################################################################# +add_to_startup(os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') + '/startup_script.py', pm2_name) +print('\nPackage added to startup.\n') print('\nPackage successfully deployed to: ', deploy_path, '\n') \ No newline at end of file diff --git a/startup_script.py b/startup_script.py new file mode 100644 index 0000000..3b585e6 --- /dev/null +++ b/startup_script.py @@ -0,0 +1,2 @@ +import powershell +powershell.run_command_no_dir('pm2 resurrect --no-treekill') \ No newline at end of file