querysub 0.205.0 → 0.207.0
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/package.json
CHANGED
|
@@ -70,9 +70,8 @@ async function main() {
|
|
|
70
70
|
} catch {}
|
|
71
71
|
await fs.promises.unlink(prevPath);
|
|
72
72
|
}
|
|
73
|
-
await fs.promises.writeFile(prevPath, process.pid);
|
|
73
|
+
await fs.promises.writeFile(prevPath, process.pid + "");
|
|
74
74
|
|
|
75
|
-
console.log(`Always up pid: ${process.pid}`);
|
|
76
75
|
while (true) {
|
|
77
76
|
try {
|
|
78
77
|
await runCommandWithLogging(`yarn machine ${process.pid}`);
|
|
@@ -40,7 +40,7 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
40
40
|
|
|
41
41
|
const SCREEN_SUFFIX = "-dply";
|
|
42
42
|
function getScreenName(config: { serviceKey: string; index: number }): string {
|
|
43
|
-
return `${config.serviceKey}-${config.index}${SCREEN_SUFFIX}`.replace(/[^a-zA-Z0-9]/g, "_");
|
|
43
|
+
return `${config.serviceKey}-${config.index}${SCREEN_SUFFIX}`.replace(/[^a-zA-Z0-9\-_]/g, "_");
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
@@ -163,6 +163,52 @@ async function main() {
|
|
|
163
163
|
// Test command to verify ssh credentials work
|
|
164
164
|
await runPromise(`ssh ${sshRemote} whoami`);
|
|
165
165
|
|
|
166
|
+
// Setup swap space if not already configured
|
|
167
|
+
console.log("Checking swap configuration...");
|
|
168
|
+
const swapInfo = await runPromise(`ssh ${sshRemote} "free -m | grep Swap"`);
|
|
169
|
+
const swapTotal = parseInt(swapInfo.split(/\s+/)[1]);
|
|
170
|
+
|
|
171
|
+
// Get RAM amount to calculate appropriate swap size
|
|
172
|
+
const memInfo = await runPromise(`ssh ${sshRemote} "free -m | grep Mem"`);
|
|
173
|
+
const ramMB = parseInt(memInfo.split(/\s+/)[1]);
|
|
174
|
+
if (swapTotal > 0) {
|
|
175
|
+
console.log(`✅ Swap already configured: ${swapTotal}MB SWAP vs ${ramMB}MB REAL MEMORY`);
|
|
176
|
+
} else {
|
|
177
|
+
// Calculate swap size based on RAM:
|
|
178
|
+
// < 2GB RAM: 2x RAM
|
|
179
|
+
// 2-8GB RAM: 1x RAM
|
|
180
|
+
// > 8GB RAM: 0.5x RAM (minimum 4GB)
|
|
181
|
+
let swapSizeMB: number;
|
|
182
|
+
if (ramMB < 2048) {
|
|
183
|
+
swapSizeMB = ramMB * 2;
|
|
184
|
+
} else if (ramMB <= 8192) {
|
|
185
|
+
swapSizeMB = ramMB;
|
|
186
|
+
} else {
|
|
187
|
+
swapSizeMB = Math.max(Math.floor(ramMB * 0.5), 4096);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
console.log(`Setting up swap space (${Math.round(swapSizeMB / 1024 * 10) / 10}GB for ${Math.round(ramMB / 1024 * 10) / 10}GB RAM)...`);
|
|
191
|
+
|
|
192
|
+
// Create swap file with calculated size
|
|
193
|
+
await runPromise(`ssh ${sshRemote} "sudo fallocate -l ${swapSizeMB}M /swapfile"`);
|
|
194
|
+
|
|
195
|
+
// Set correct permissions
|
|
196
|
+
await runPromise(`ssh ${sshRemote} "sudo chmod 600 /swapfile"`);
|
|
197
|
+
|
|
198
|
+
// Set up the swap area
|
|
199
|
+
await runPromise(`ssh ${sshRemote} "sudo mkswap /swapfile"`);
|
|
200
|
+
|
|
201
|
+
// Enable the swap file
|
|
202
|
+
await runPromise(`ssh ${sshRemote} "sudo swapon /swapfile"`);
|
|
203
|
+
|
|
204
|
+
// Make swap persistent across reboots
|
|
205
|
+
await runPromise(`ssh ${sshRemote} "echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab"`);
|
|
206
|
+
|
|
207
|
+
// Verify swap is working
|
|
208
|
+
const swapCheck = await runPromise(`ssh ${sshRemote} "free -m | grep Swap"`);
|
|
209
|
+
console.log(`✅ Swap configured: ${swapCheck.split(/\s+/)[1]}MB total vs ${ramMB}MB REAL MEMORY`);
|
|
210
|
+
}
|
|
211
|
+
|
|
166
212
|
let backblazePath = getBackblazePath();
|
|
167
213
|
|
|
168
214
|
console.log("Setting up machine:", sshRemote);
|