mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 00:14:15 +00:00
fix(proxy): persist daemon state after startup
This commit is contained in:
1 parent
8ad2763942
commit
c0c119867a
3 files changed
+8
-4
No files matched your search
@@ -33,7 +33,7 @@ export function findPositionalArg(
|
|||||||
for (let i = 0; i < args.length; i += 1) {
|
for (let i = 0; i < args.length; i += 1) {
|
||||||
const arg = args[i];
|
const arg = args[i];
|
||||||
if (arg === '--') {
|
if (arg === '--') {
|
||||||
return args[i + 1];
|
return i + 1 < args.length ? args[i + 1] : undefined;
|
||||||
}
|
}
|
||||||
if (arg.startsWith('-')) {
|
if (arg.startsWith('-')) {
|
||||||
if (optionsWithValues.includes(arg)) {
|
if (optionsWithValues.includes(arg)) {
|
||||||
|
|||||||
@@ -467,14 +467,14 @@ export async function startOpenAICompatProxy(
|
|||||||
proc.stderr?.on('data', (chunk) => {
|
proc.stderr?.on('data', (chunk) => {
|
||||||
stderr += chunk;
|
stderr += chunk;
|
||||||
});
|
});
|
||||||
if (persistState) {
|
|
||||||
commitState();
|
|
||||||
}
|
|
||||||
|
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const poll = async () => {
|
const poll = async () => {
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
if (await isOpenAICompatProxyRunning(port)) {
|
if (await isOpenAICompatProxyRunning(port)) {
|
||||||
|
if (persistState) {
|
||||||
|
commitState();
|
||||||
|
}
|
||||||
finish({
|
finish({
|
||||||
success: true,
|
success: true,
|
||||||
pid: proc.pid,
|
pid: proc.pid,
|
||||||
|
|||||||
@@ -9,4 +9,8 @@ describe('findPositionalArg', () => {
|
|||||||
it('treats arguments after -- as positional', () => {
|
it('treats arguments after -- as positional', () => {
|
||||||
expect(findPositionalArg(['--', '--port', '3456'], ['--port'])).toBe('--port');
|
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