diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index cb0dc65..df4c161 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,5 @@ name: PR + on: pull_request: diff --git a/hostd/main/daemon.ts b/hostd/main/daemon.ts index 512cb25..ae30464 100644 --- a/hostd/main/daemon.ts +++ b/hostd/main/daemon.ts @@ -1,17 +1,17 @@ import { spawn } from 'child_process' import { state } from './state' import { getConfig, getConfigFilePath } from './config' +import { getBinaryDirectoryPath, getBinaryFilePath } from './binary' import path from 'path' import fs from 'fs' -import { getBinaryDirectoryPath, getBinaryFilePath } from './binary' export async function startDaemon(): Promise { try { await stopDaemon() const config = getConfig() const binaryFilePath = getBinaryFilePath() - state.daemon = spawn(binaryFilePath, ['-env'], { - env: { ...process.env, HOSTD_CONFIG_FILE: getConfigFilePath() }, + state.daemon = spawn(binaryFilePath, [], { + env: { ...process.env, RENTERD_CONFIG_FILE: getConfigFilePath() }, cwd: config.directory, }) @@ -25,12 +25,16 @@ export async function startDaemon(): Promise { // Emit events or log data as needed }) + state.daemon.on('error', (err) => { + console.log(`child process exited with error ${err}`) + state.daemon = null + }) + state.daemon.on('close', (code) => { console.log(`child process exited with code ${code}`) state.daemon = null }) } catch (err) { - console.log('Failed to start daemon', err) state.daemon = null throw err } diff --git a/hostd/renderer/components/useConfigData.tsx b/hostd/renderer/components/useConfigData.tsx index cc297ec..f93ed2a 100644 --- a/hostd/renderer/components/useConfigData.tsx +++ b/hostd/renderer/components/useConfigData.tsx @@ -28,9 +28,7 @@ export function useConfigData() { return useSWR( 'config', async () => { - const config = await window.electron.getConfig() - console.log(config) - return config + return window.electron.getConfig() }, { refreshInterval: 10_000, diff --git a/renterd/main/daemon.ts b/renterd/main/daemon.ts index f44c7bd..ae30464 100644 --- a/renterd/main/daemon.ts +++ b/renterd/main/daemon.ts @@ -25,14 +25,17 @@ export async function startDaemon(): Promise { // Emit events or log data as needed }) + state.daemon.on('error', (err) => { + console.log(`child process exited with error ${err}`) + state.daemon = null + }) + state.daemon.on('close', (code) => { console.log(`child process exited with code ${code}`) state.daemon = null }) } catch (err) { - console.log('Failed to start daemon', err) state.daemon = null - console.log('state is', state) throw err } } @@ -54,7 +57,6 @@ export function stopDaemon(): Promise { } export function getIsDaemonRunning(): boolean { - console.log('daemon', state) return !!state.daemon && !state.daemon.killed } diff --git a/renterd/renderer/components/Header.tsx b/renterd/renderer/components/Header.tsx index 0294e05..9171466 100644 --- a/renterd/renderer/components/Header.tsx +++ b/renterd/renderer/components/Header.tsx @@ -18,7 +18,6 @@ export function Header() { useConfig() const config = useConfigData() const installedVersion = useInstalledVersion() - console.log(isRunning.data) return ( ( 'config', async () => { - const config = await window.electron.getConfig() - console.log(config) - return config + return window.electron.getConfig() }, { refreshInterval: 10_000, diff --git a/renterd/renderer/contexts/config/index.tsx b/renterd/renderer/contexts/config/index.tsx index fe3e8cd..d591e2a 100644 --- a/renterd/renderer/contexts/config/index.tsx +++ b/renterd/renderer/contexts/config/index.tsx @@ -114,7 +114,7 @@ function useConfigMain() { setSettings({ password: values.httpPassword, }) - if (notConfiguredYet) { + if (closeWindowAfterSave) { window.electron.closeWindow() } } catch (e) {