mirror of
https://github.com/open-webui/desktop
synced 2025-06-26 18:15:59 +00:00
refac
This commit is contained in:
parent
825516be11
commit
30edf4d3c8
47
src/main.ts
47
src/main.ts
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user