| 9 | }); |
| 10 | |
| 11 | async function run() { |
| 12 | await new Promise(r => server.listen(39100, '127.0.0.1', r)); |
| 13 | console.log('[SERVER] Listening on 39100'); |
| 14 | |
| 15 | const vm = new AgentVM({ |
| 16 | wasmPath: '/home/andreas/git/gh/agentvm/agentvm-alpine-python.wasm.v1', |
| 17 | env: {}, |
| 18 | mountDir: '/tmp', |
| 19 | debug: true |
| 20 | }); |
| 21 | |
| 22 | // Wait for VM to be ready |
| 23 | await new Promise(r => vm.once('ready', r)); |
| 24 | console.log('[VM] Ready'); |
| 25 | |
| 26 | console.log('\n=== Starting Request 1 ==='); |
| 27 | const r1 = await vm.exec('curl -s -m 5 http://192.168.1.1:39100/test1'); |
| 28 | console.log('Request 1 result:', r1.stdout.toString().trim() || '(empty)', '| exit:', r1.exitCode); |
| 29 | |
| 30 | // Add a delay between requests |
| 31 | console.log('\nWaiting 1 second...'); |
| 32 | await new Promise(r => setTimeout(r, 1000)); |
| 33 | |
| 34 | console.log('\n=== Starting Request 2 ==='); |
| 35 | const r2 = await vm.exec('curl -s -m 5 http://192.168.1.1:39100/test2'); |
| 36 | console.log('Request 2 result:', r2.stdout.toString().trim() || '(empty)', '| exit:', r2.exitCode); |
| 37 | |
| 38 | vm.kill(); |
| 39 | server.close(); |
| 40 | } |
| 41 | |
| 42 | run().catch(e => { console.error(e); process.exit(1); }); |