cloud-pc-templates 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/handlers/ollamacloud.js +35 -19
- package/package.json +1 -1
package/handlers/ollamacloud.js
CHANGED
|
@@ -97,30 +97,46 @@ async function downloadAndRunProxy(endpoint) {
|
|
|
97
97
|
// Get API key from user
|
|
98
98
|
const apiKey = await promptForApiKey();
|
|
99
99
|
|
|
100
|
-
// Run the proxy with API key passed as
|
|
100
|
+
// Run the proxy with API key passed as command-line argument
|
|
101
101
|
return new Promise((resolve, reject) => {
|
|
102
|
-
const
|
|
103
|
-
const child = spawn('node', [tempFile], { env });
|
|
102
|
+
const child = spawn('node', [tempFile, apiKey]);
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
console.log(` - Endpoint: ${endpoint}`);
|
|
116
|
-
}
|
|
117
|
-
resolve();
|
|
118
|
-
}, 1000);
|
|
119
|
-
} else {
|
|
120
|
-
reject(new Error('Proxy process failed'));
|
|
104
|
+
let serverReady = false;
|
|
105
|
+
|
|
106
|
+
// Capture stdout to detect when server is ready
|
|
107
|
+
child.stdout.on('data', (data) => {
|
|
108
|
+
const output = data.toString();
|
|
109
|
+
console.log(output);
|
|
110
|
+
|
|
111
|
+
// Check if server indicates it's ready
|
|
112
|
+
if (output.includes('listening') || output.includes('started') || output.includes('running')) {
|
|
113
|
+
serverReady = true;
|
|
121
114
|
}
|
|
122
115
|
});
|
|
123
116
|
|
|
117
|
+
// Capture stderr for error messages
|
|
118
|
+
child.stderr.on('data', (data) => {
|
|
119
|
+
console.error(data.toString());
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Wait a bit for server to start, then validate
|
|
123
|
+
setTimeout(async () => {
|
|
124
|
+
try {
|
|
125
|
+
const isHealthy = await checkHealthEndpoint(endpoint);
|
|
126
|
+
if (isHealthy) {
|
|
127
|
+
console.log('✓ Logged in');
|
|
128
|
+
console.log(` - Endpoint checked: ${endpoint}`);
|
|
129
|
+
resolve();
|
|
130
|
+
} else {
|
|
131
|
+
console.log('✓ Proxy started');
|
|
132
|
+
console.log(` - Endpoint: ${endpoint}`);
|
|
133
|
+
resolve();
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
reject(error);
|
|
137
|
+
}
|
|
138
|
+
}, 2000);
|
|
139
|
+
|
|
124
140
|
child.on('error', reject);
|
|
125
141
|
});
|
|
126
142
|
}
|