mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-07 16:03:07 +00:00
Sets dataDir and logDir in config. Defaults to user-accessible folder.
This commit is contained in:
parent
e97493c183
commit
ba2aae04a9
@ -9,7 +9,7 @@ import { runCommand } from '../utils/command.js';
|
|||||||
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
||||||
import { checkDependencies } from '../services/nodeService.js';
|
import { checkDependencies } from '../services/nodeService.js';
|
||||||
import { saveConfig } from '../services/config.js';
|
import { saveConfig } from '../services/config.js';
|
||||||
import { getCodexInstallPath } from '../utils/appdata.js';
|
import { getCodexInstallPath, getCodexDataDirDefaultPath, getCodexLogsPath } from '../utils/appdata.js';
|
||||||
|
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
|
|
||||||
@ -83,6 +83,8 @@ export async function checkCodexInstallation(config, showNavigationMenu) {
|
|||||||
|
|
||||||
async function saveCodexExePathToConfig(config, codexExePath) {
|
async function saveCodexExePathToConfig(config, codexExePath) {
|
||||||
config.codexExe = codexExePath;
|
config.codexExe = codexExePath;
|
||||||
|
config.dataDir = getCodexDataDirDefaultPath();
|
||||||
|
config.logsDir = getCodexLogsPath();
|
||||||
if (!fs.existsSync(config.codexExe)) {
|
if (!fs.existsSync(config.codexExe)) {
|
||||||
console.log(showErrorMessage(`Codex executable not found in expected path: ${config.codexExe}`));
|
console.log(showErrorMessage(`Codex executable not found in expected path: ${config.codexExe}`));
|
||||||
throw new Error("Exe not found");
|
throw new Error("Exe not found");
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
import path from 'path';
|
||||||
import { createSpinner } from 'nanospinner';
|
import { createSpinner } from 'nanospinner';
|
||||||
import { runCommand } from '../utils/command.js';
|
import { runCommand } from '../utils/command.js';
|
||||||
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
||||||
import { isNodeRunning, isCodexInstalled, logToSupabase, startPeriodicLogging, getWalletAddress, setWalletAddress } from '../services/nodeService.js';
|
import { isNodeRunning, isCodexInstalled, startPeriodicLogging, getWalletAddress, setWalletAddress } from '../services/nodeService.js';
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import boxen from 'boxen';
|
import boxen from 'boxen';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
@ -27,6 +28,13 @@ async function promptForWalletAddress() {
|
|||||||
return wallet || null;
|
return wallet || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentLogFile(config) {
|
||||||
|
const timestamp = new Date().toISOString()
|
||||||
|
.replaceAll(":", "-")
|
||||||
|
.replaceAll(".", "-");
|
||||||
|
return path.join(config.logsDir, `codex_${timestamp}.log`);
|
||||||
|
}
|
||||||
|
|
||||||
export async function runCodex(config, showNavigationMenu) {
|
export async function runCodex(config, showNavigationMenu) {
|
||||||
const isInstalled = await isCodexInstalled(config);
|
const isInstalled = await isCodexInstalled(config);
|
||||||
if (!isInstalled) {
|
if (!isInstalled) {
|
||||||
@ -65,9 +73,19 @@ export async function runCodex(config, showNavigationMenu) {
|
|||||||
nat = await runCommand('curl -s https://ip.codex.storage');
|
nat = await runCommand('curl -s https://ip.codex.storage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.dataDir.length < 1) throw new Error("Missing config: dataDir");
|
||||||
|
if (config.logsDir.length < 1) throw new Error("Missing config: logsDir");
|
||||||
|
const logFilePath = getCurrentLogFile(config);
|
||||||
|
|
||||||
|
console.log(showInfoMessage(
|
||||||
|
`Data location: ${config.dataDir}\n` +
|
||||||
|
`Logs: ${logFilePath}`
|
||||||
|
));
|
||||||
|
|
||||||
const executable = config.codexExe;
|
const executable = config.codexExe;
|
||||||
const args = [
|
const args = [
|
||||||
`--data-dir=datadir`,
|
`--data-dir=${config.dataDir}`,
|
||||||
|
`--log-file=${logFilePath}`,
|
||||||
`--disc-port=${discPort}`,
|
`--disc-port=${discPort}`,
|
||||||
`--listen-addrs=/ip4/0.0.0.0/tcp/${listenPort}`,
|
`--listen-addrs=/ip4/0.0.0.0/tcp/${listenPort}`,
|
||||||
`--nat=${nat}`,
|
`--nat=${nat}`,
|
||||||
|
|||||||
@ -7,7 +7,8 @@ const defaultConfig = {
|
|||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// Save user-selected config options. Use these when starting Codex.
|
// Save user-selected config options. Use these when starting Codex.
|
||||||
// dataDir: "",
|
dataDir: "",
|
||||||
|
logsDir: ""
|
||||||
// storageQuota: 0,
|
// storageQuota: 0,
|
||||||
// ports: {
|
// ports: {
|
||||||
// discPort: 8090,
|
// discPort: 8090,
|
||||||
|
|||||||
@ -2,17 +2,26 @@ import path from 'path';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
export function getAppDataDir() {
|
export function getAppDataDir() {
|
||||||
return getExists("codex-cli");
|
return ensureExists(appData("codex-cli"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCodexInstallPath() {
|
export function getCodexInstallPath() {
|
||||||
return getExists("codex");
|
return ensureExists(path.join(appData("codex"), "bin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExists(appName) {
|
export function getCodexDataDirDefaultPath() {
|
||||||
const dir = appData(appName);
|
// This path does not exist on first startup. That's good: Codex will
|
||||||
|
// create it with the required access permissions.
|
||||||
|
return path.join(appData("codex"), "datadir");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCodexLogsPath() {
|
||||||
|
return ensureExists(path.join(appData("codex"), "logs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureExists(dir) {
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
fs.mkdirSync(dir);
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user