This commit is contained in:
Timothy Jaeryang Baek 2025-01-13 23:55:36 -08:00
parent 825516be11
commit 30edf4d3c8
2 changed files with 35 additions and 37 deletions

View File

@ -99,34 +99,34 @@ if (!gotTheLock) {
...(SERVER_STATUS === 'started'
? [
{
label: 'Stop Server',
click: async () => {
await stopAllServers();
SERVER_STATUS = 'stopped';
mainWindow.webContents.send('main:data', {
type: 'server:status',
data: SERVER_STATUS
});
updateTrayMenu('Open WebUI: Stopped', null); // Update tray menu with stopped status
}
{
label: 'Stop Server',
click: async () => {
await stopAllServers();
SERVER_STATUS = 'stopped';
mainWindow.webContents.send('main:data', {
type: 'server:status',
data: SERVER_STATUS
});
updateTrayMenu('Open WebUI: Stopped', null); // Update tray menu with stopped status
}
]
}
]
: SERVER_STATUS === 'starting'
? [
{
label: 'Starting Server...',
enabled: false
}
]
{
label: 'Starting Server...',
enabled: false
}
]
: [
{
label: 'Start Server',
click: async () => {
await startServerHandler();
}
{
label: 'Start Server',
click: async () => {
await startServerHandler();
}
]),
}
]),
{
type: 'separator'
@ -174,7 +174,6 @@ if (!gotTheLock) {
type: 'server:status',
data: SERVER_STATUS
});
mainWindow.loadURL(SERVER_URL);
const urlObj = new URL(SERVER_URL);

View File

@ -401,16 +401,14 @@ export async function startServer(installationPath?: string, port?: number): Pro
return;
}
let startCommand =
process.platform === 'win32'
? `"${installationPath}\\Scripts\\activate.bat" && set DATA_DIR="${path.join(
app.getPath('userData'),
'data'
)}" && set WEBUI_SECRET_KEY=${getSecretKey()} && open-webui serve`
: `source "${installationPath}/bin/activate" && export DATA_DIR="${path.join(
app.getPath('userData'),
'data'
)}" && export WEBUI_SECRET_KEY=${getSecretKey()} && open-webui serve`;
let startCommand = process.platform === 'win32'
? `"${installationPath}\\Scripts\\activate.bat" && open-webui serve`
: `source "${installationPath}/bin/activate" && open-webui serve`;
// Set environment variables in a platform-agnostic way
process.env.DATA_DIR = path.join(app.getPath('userData'), 'data');
process.env.WEBUI_SECRET_KEY = getSecretKey();
port = port || 8080;
while (await portInUse(port)) {
@ -419,13 +417,14 @@ export async function startServer(installationPath?: string, port?: number): Pro
startCommand += ` --port ${port}`;
console.log('Starting Open-WebUI server...');
console.log('Starting Open-WebUI server...', startCommand);
logEmitter.emit('log', 'Starting Open-WebUI server...'); // Emit log
const childProcess = spawn(startCommand, {
shell: true,
detached: true,
stdio: ['ignore', 'pipe', 'pipe'] // Let us capture logs via stdout/stderr
detached: false,
stdio: ['ignore', 'pipe'], // Let us capture logs via stdout/stderr
windowsHide: true
});
let serverCrashed = false;