refactor(daemon): Adopt new endo path names
MODIFY
packages/daemon/daemon.js
packages/daemon/daemon.js
@@ -50,23 +50,23 @@ export const main = async () => {
console.error('Endo exiting');
});
- if (process.argv.length < 4) {
+ if (process.argv.length < 5) {
throw new Error(
- `daemon.js requires arguments [sockPath] [endoPath], got ${process.argv.join(
+ `daemon.js requires arguments [sockPath] [statePath] [cachePath], got ${process.argv.join(
', ',
)}`,
);
}
const sockPath = process.argv[2];
- const endoPath = process.argv[3];
+ const statePath = process.argv[3];
const cachePath = process.argv[4];
- const locator = { sockPath, endoPath, cachePath };
+ const locator = { sockPath, statePath, cachePath };
const endoFacets = makeEndoFacets(locator);
- await fs.promises.mkdir(endoPath, { recursive: true });
+ await fs.promises.mkdir(statePath, { recursive: true });
const server = net.createServer();

MODIFY
packages/daemon/index.d.ts
packages/daemon/index.d.ts
type Locator = {
- endoPath: string;
+ statePath: string;
cachePath: string;
sockPath: string;
};

MODIFY
packages/daemon/index.js
packages/daemon/index.js
@@ -13,11 +13,11 @@ import fs from 'fs';
import path from 'path';
import { E } from '@endo/eventual-send';
-import { whereEndo, whereEndoSock, whereEndoCache } from '@endo/where';
+import { whereEndoState, whereEndoSock, whereEndoCache } from '@endo/where';
import { makeEndoClient } from './src/client.js';
const defaultLocator = {
- endoPath: whereEndo(process.platform, process.env),
+ statePath: whereEndoState(process.platform, process.env),
sockPath: whereEndoSock(process.platform, process.env),
cachePath: whereEndoCache(process.platform, process.env),
};
@@ -35,17 +35,28 @@ export const shutdown = async (locator = defaultLocator) => {
};
export const start = async (locator = defaultLocator) => {
- await fs.promises.mkdir(locator.endoPath, { recursive: true });
+ const cachePathCreated = fs.promises.mkdir(locator.cachePath, {
+ recursive: true,
+ });
+ const statePathCreated = fs.promises.mkdir(locator.statePath, {
+ recursive: true,
+ });
+
+ await cachePathCreated;
const logPath = path.join(locator.cachePath, 'endo.log');
+
+ await statePathCreated;
const output = fs.openSync(logPath, 'a');
+
const child = popen.fork(
endoDaemonPath,
- [locator.sockPath, locator.endoPath, locator.cachePath],
+ [locator.sockPath, locator.statePath, locator.cachePath],
{
detached: true,
stdio: ['ignore', output, output, 'ipc'],
},
);
+
return new Promise((resolve, reject) => {
child.on('error', (/** @type {Error} */ cause) => {
reject(

MODIFY
packages/daemon/test/test-endo.js
packages/daemon/test/test-endo.js
@@ -10,12 +10,12 @@ const { raw } = String;
const dirname = url.fileURLToPath(new URL('.', import.meta.url)).toString();
const locator = {
- endoPath: path.join(dirname, 'endo'),
+ statePath: path.join(dirname, 'endo'),
+ cachePath: dirname,
sockPath:
process.platform === 'win32'
? raw`\\?\pipe\endo-test.sock`
: path.join(dirname, 'endo.sock'),
- cachePath: dirname,
};
test.serial('lifecycle', async t => {

refactor(daemon): Adopt new endo path names