Documentation Index
Fetch the complete documentation index at: https://ppio.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
要在后台运行命令,请向 commands.run() 方法开启 background 选项,启用后,运行 commands.run() 方法会立即返回,命令将继续在沙箱中运行。使用 commands.kill() 方法可以终止该命令。
import { Sandbox } from 'ppio-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
// 在后台运行命令
const command = await sandbox.commands.run('echo hello; sleep 10; echo world', {
background: true,
onStdout: (data) => {
console.log(data)
},
})
// 终止命令
await command.kill()
await sandbox.kill()