This commit is contained in:
Adrian Gunnar Lauterer 2024-09-08 03:52:35 +02:00
parent 20a26b2a64
commit 0f06a245c1
4 changed files with 19 additions and 32 deletions

View File

@ -32,21 +32,13 @@
postInstall = '' postInstall = ''
mkdir -p $out/share/ozai_webui/static mkdir -p $out/share/ozai_webui/static
mkdir -p $out/share/ozai_webui/templates mkdir -p $out/share/ozai_webui/templates
mkdir -p $out/lib/python3.11/site-packages/ozai_webui/templates mkdir -p $out/lib/python3.12/site-packages/ozai_webui/templates
mkdir -p $out/lib/python3.11/site-packages/ozai_webui/static mkdir -p $out/lib/python3.12/site-packages/ozai_webui/static
mkdir -p $out/lib/python3.11/site-packages/templates
mkdir -p $out/lib/python3.11/site-packages/static
mkdir -p $out/lib/python3.11/templates
mkdir -p $out/lib/python3.11/static
install -Dm444 ${src}/static/* $out/share/ozai_webui/static/ install -Dm444 ${src}/static/* $out/share/ozai_webui/static/
install -Dm444 ${src}/templates/* $out/share/ozai_webui/templates/ install -Dm444 ${src}/templates/* $out/share/ozai_webui/templates/
cp -r $src/templates/* $out/lib/python3.11/site-packages/ozai_webui/templates cp -r $src/templates/* $out/lib/python3.12/site-packages/ozai_webui/templates
cp -r $src/templates/* $out/lib/python3.11/site-packages/templates cp -r $src/static/* $out/lib/python3.12/site-packages/ozai_webui/static
cp -r $src/templates/* $out/lib/python3.11/templates
cp -r $src/static/* $out/lib/python3.11/site-packages/ozai_webui/static
cp -r $src/static/* $out/lib/python3.11/site-packages/static
cp -r $src/static/* $out/lib/python3.11/static
''; '';
}; };
@ -78,10 +70,10 @@ packages.x86_64-linux.ozai-webui-run = pkgs.stdenv.mkDerivation rec {
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
mkdir -p $out/share/ozai_webui/static # mkdir -p $out/share/ozai_webui/static
mkdir -p $out/share/ozai_webui/templates # mkdir -p $out/share/ozai_webui/templates
mkdir -p $out/bin/templates # mkdir -p $out/bin/templates
mkdir -p $out/bin/static # mkdir -p $out/bin/static
cp -r $src/* $out/bin cp -r $src/* $out/bin
cp $src/run.sh $out/bin/run cp $src/run.sh $out/bin/run
chmod +x $out/bin/run chmod +x $out/bin/run
@ -133,9 +125,9 @@ packages.x86_64-linux.ozai-webui-run = pkgs.stdenv.mkDerivation rec {
serviceConfig = { serviceConfig = {
#ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/bin"; #ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/bin";
ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/lib/python3.11/site-packages/"; # ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/lib/python3.11/site-packages/";
# ExecStart = "${self.packages.x86_64-linux.ozai-webui}/bin/ozai-webui"; # ExecStart = "${self.packages.x86_64-linux.ozai-webui}/bin/ozai-webui";
# ExecStart = "${self.packages.x86_64-linux.default}/bin/ozai_webui"; ExecStart = "${self.packages.x86_64-linux.default}/bin/ozai_webui --host ${config.services.ozai-webui.host} --port ${toString(config.services.ozai-webui.port)} --ozai_url ${config.services.ozai-webui.ozaiUrl} --static_folder ${self.packages.x86_64-linux.default}/share/ozai-webui/static --template_folder ${self.packages.x86_64-linux.default}/share/ozai-webui/templates";
Restart = "always"; Restart = "always";
}; };
}; };

2
result
View File

@ -1 +1 @@
/nix/store/v6rmds7152d3cg3h77kjsg1kfvmgz108-ozai-webui-run-0.1.1 /nix/store/djg747ccyvdlbcpf72617vi92p6vkah5-python3.11-ozai-webui-0.1.1

1
result-1 Symbolic link
View File

@ -0,0 +1 @@
/nix/store/jbsrzl3556rkm5amzx1xrjcwwdvry1qk-ozai-webui-run-0.1.1

View File

@ -25,29 +25,18 @@ if os.getenv('OZAI_WEBUI_STATIC_FOLDER') is not None:
if os.getenv('OZAI_WEBUI_TEMPLATE_FOLDER') is not None: if os.getenv('OZAI_WEBUI_TEMPLATE_FOLDER') is not None:
template_folder = os.getenv('OZAI_WEBUI_TEMPLATE_FOLDER') template_folder = os.getenv('OZAI_WEBUI_TEMPLATE_FOLDER')
print(f"using host { ozai_webui_host }")
print(f"using port { ozai_webui_port }")
print(f"using ozai url { ozai_url }")
print(f"using template folder { template_folder }")
print(f"using static folder { static_folder }")
app = Flask(__name__,template_folder=template_folder,static_folder=static_folder ) app = Flask(__name__,template_folder=template_folder,static_folder=static_folder )
socketio = SocketIO(app) socketio = SocketIO(app)
app.config['SECRET_KEY'] = "secret" app.config['SECRET_KEY'] = "secret"
parser = argparse.ArgumentParser(description="Run the Ozai WebUI server") parser = argparse.ArgumentParser(description="Run the Ozai WebUI server")
parser.add_argument('-H', '--host', type=str, default=ozai_webui_host, help='The host to run the server on') parser.add_argument('-H', '--host', type=str, default=ozai_webui_host, help='The host to run the server on')
parser.add_argument('-P', '--port', type=int, default=ozai_webui_port, help='The port to run the server on') parser.add_argument('-P', '--port', type=int, default=ozai_webui_port, help='The port to run the server on')
parser.add_argument('-O', '--ozai_url', type=str, default=ozai_url, help='The URL of the Ozai server') parser.add_argument('-O', '--ozai_url', type=str, default=ozai_url, help='The URL of the Ozai server')
parser.add_argument('-S', '--secret_key', type=str, default=app.config['SECRET_KEY'], help='The secret key for the Flask app') parser.add_argument('-S', '--secret_key', type=str, default=app.config['SECRET_KEY'], help='The secret key for the Flask app')
parser.add_argument('--static_folder', type=str, default=static_folder, help='The location of the static folder') parser.add_argument('--static_folder', type=str, default=static_folder, help='The location of the static folder')
parser.add_argument('--template_folder', type=str, default=template_folder, help='The location of the template folder') parser.add_argument('--template_folder', type=str, default=template_folder, help='The location of the template folder')
args = parser.parse_args() args = parser.parse_args()
if args.host: if args.host:
ozai_webui_host = args.host ozai_webui_host = args.host
if args.port: if args.port:
@ -61,6 +50,11 @@ if args.static_folder:
if args.template_folder: if args.template_folder:
app.template_folder = args.template_folder app.template_folder = args.template_folder
print(f"using host { ozai_webui_host }")
print(f"using port { ozai_webui_port }")
print(f"using ozai url { ozai_url }")
print(f"using template folder { template_folder }")
print(f"using static folder { static_folder }")
#home page #home page
@app.route('/') @app.route('/')
@ -220,9 +214,9 @@ def ws_message(data):
socketio.emit('move_status', response.text, room=game_id) socketio.emit('move_status', response.text, room=game_id)
def main (): def main ():
app.run(host=ozai_webui_host, port=ozai_webui_port)
# return socketio.run(app, debug=False, host=ozai_webui_host, port=ozai_webui_port, allow_unsafe_werkzeug=True) # return socketio.run(app, debug=False, host=ozai_webui_host, port=ozai_webui_port, allow_unsafe_werkzeug=True)
# return socketio.run(app, debug=False, host=ozai_webui_host, port=ozai_webui_port) return socketio.run(app, debug=False, host=ozai_webui_host, port=ozai_webui_port)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
#app.run(host=ozai_webui_host, port=ozai_webui_port)