mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(proxy): persist daemon state after startup
This commit is contained in:
@@ -33,7 +33,7 @@ export function findPositionalArg(
|
||||
for (let i = 0; i < args.length; i += 1) {
|
||||
const arg = args[i];
|
||||
if (arg === '--') {
|
||||
return args[i + 1];
|
||||
return i + 1 < args.length ? args[i + 1] : undefined;
|
||||
}
|
||||
if (arg.startsWith('-')) {
|
||||
if (optionsWithValues.includes(arg)) {
|
||||
|
||||
@@ -467,14 +467,14 @@ export async function startOpenAICompatProxy(
|
||||
proc.stderr?.on('data', (chunk) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
if (persistState) {
|
||||
commitState();
|
||||
}
|
||||
|
||||
let attempts = 0;
|
||||
const poll = async () => {
|
||||
attempts += 1;
|
||||
if (await isOpenAICompatProxyRunning(port)) {
|
||||
if (persistState) {
|
||||
commitState();
|
||||
}
|
||||
finish({
|
||||
success: true,
|
||||
pid: proc.pid,
|
||||
|
||||
@@ -9,4 +9,8 @@ describe('findPositionalArg', () => {
|
||||
it('treats arguments after -- as positional', () => {
|
||||
expect(findPositionalArg(['--', '--port', '3456'], ['--port'])).toBe('--port');
|
||||
});
|
||||
|
||||
it('returns undefined when -- is the final argument', () => {
|
||||
expect(findPositionalArg(['--'], ['--port'])).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user