diff --git a/engine/main.cc b/engine/main.cc index 1e97384c8..afe843817 100644 --- a/engine/main.cc +++ b/engine/main.cc @@ -109,6 +109,9 @@ void RunServer(std::optional port) { drogon::app().registerController(pm_ctl); drogon::app().registerController(server_ctl); + auto upload_path = std::filesystem::temp_directory_path() / "cortex-uploads"; + drogon::app().setUploadPath(upload_path.string()); + LOG_INFO << "Server started, listening at: " << config.apiServerHost << ":" << config.apiServerPort; LOG_INFO << "Please load your model"; diff --git a/engine/templates/linux/postinst b/engine/templates/linux/postinst index 401b9f4b8..583639b5e 100644 --- a/engine/templates/linux/postinst +++ b/engine/templates/linux/postinst @@ -9,3 +9,4 @@ fi USER_TO_RUN_AS=${SUDO_USER:-$(whoami)} echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS" sudo -u $USER_TO_RUN_AS env PATH=$PATH:/usr/lib/wsl/lib /usr/bin/$DESTINATION_BINARY_NAME engines install llama-cpp +sudo -u $USER_TO_RUN_AS env PATH=$PATH:/usr/lib/wsl/lib /usr/bin/$DESTINATION_BINARY_NAME stop diff --git a/engine/templates/macos/postinstall b/engine/templates/macos/postinstall index 6d06c673d..38310a452 100644 --- a/engine/templates/macos/postinstall +++ b/engine/templates/macos/postinstall @@ -11,9 +11,15 @@ fi USER_TO_RUN_AS=$(stat -f "%Su" /dev/console) +echo "Start server before downloading server for user $USER_TO_RUN_AS" +sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME start + echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS" sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME engines install llama-cpp +echo "Stop server" +sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME stop + sudo chown -R $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" sudo chown $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" diff --git a/engine/templates/windows/installer-beta.iss b/engine/templates/windows/installer-beta.iss index 7bb937d11..b8524afd0 100644 --- a/engine/templates/windows/installer-beta.iss +++ b/engine/templates/windows/installer-beta.iss @@ -36,7 +36,7 @@ Filename: "{app}\cortex-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cort procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine, CortexInstallCmd: String; + CmdLine, CortexInstallCmd, CortexStopServerCmd: String; ResultCode: Integer; i: Integer; SkipPostInstall: Boolean; @@ -84,6 +84,10 @@ begin CortexInstallCmd := Format('"%s\cortex-beta.exe" engines install llama-cpp', [ExpandedAppDir]); Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Stop server + CortexStopServerCmd := Format('"%s\cortex-nightly.exe" stop', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexStopServerCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Set the progress bar to 90% after downloading the engine WizardForm.ProgressGauge.Position := 90; WizardForm.ProgressGauge.Update; diff --git a/engine/templates/windows/installer-nightly.iss b/engine/templates/windows/installer-nightly.iss index 21a681234..0cf5616fc 100644 --- a/engine/templates/windows/installer-nightly.iss +++ b/engine/templates/windows/installer-nightly.iss @@ -36,7 +36,7 @@ Filename: "{app}\cortex-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping c procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine, CortexInstallCmd: String; + CmdLine, CortexInstallCmd, CortexStopServerCmd: String; ResultCode: Integer; i: Integer; SkipPostInstall: Boolean; @@ -84,6 +84,10 @@ begin CortexInstallCmd := Format('"%s\cortex-nightly.exe" engines install llama-cpp', [ExpandedAppDir]); Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Stop server + CortexStopServerCmd := Format('"%s\cortex-nightly.exe" stop', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexStopServerCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Set the progress bar to 90% after downloading the engine WizardForm.ProgressGauge.Position := 90; WizardForm.ProgressGauge.Update; diff --git a/engine/templates/windows/installer.iss b/engine/templates/windows/installer.iss index 5bbd83ec7..440d6bf93 100644 --- a/engine/templates/windows/installer.iss +++ b/engine/templates/windows/installer.iss @@ -36,7 +36,7 @@ Filename: "{app}\cortex.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine, CortexInstallCmd: String; + CmdLine, CortexInstallCmd, CortexStopServerCmd: String; ResultCode: Integer; i: Integer; SkipPostInstall: Boolean; @@ -84,6 +84,10 @@ begin CortexInstallCmd := Format('"%s\cortex.exe" engines install llama-cpp', [ExpandedAppDir]); Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Stop server + CortexStopServerCmd := Format('"%s\cortex-nightly.exe" stop', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexStopServerCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Set the progress bar to 90% after downloading the engine WizardForm.ProgressGauge.Position := 90; WizardForm.ProgressGauge.Update;