从 Foxx 应用程序执行 shell 个命令

Executing shell commands from a Foxx app

我需要从 Foxx 应用程序中执行一个二进制库 (ffmpeg)。我看到有一个内置的 child_process 模块,但它没有像 Node.js 那样的 exec 方法。还有其他方法吗?

提前致谢

由于 foxx 是同步的,我只能建议不要直接从 foxx 执行此操作。转码过程需要时间,您不希望为此阻塞数据库资源。

您应该异步执行此操作,即在节点进程中。

如果您想了解生成过程的工作原理,可以在我们的单元测试套件中找到:

https://github.com/arangodb/arangodb/blob/devel/js/client/modules/%40arangodb/testutils/process-utils.js#L878

require('internal') => {
executeExternal => launch a process to background
executeExternalAndWait => launch a process and wait for it to finish
killExternal => kill a launched process (only spawned processes can be send signals)
statusExternal => check for the status of an external process, either touch, or wait.
}

所有生成的进程都保存在服务器内部的列表中,只能操作自生成的进程。

在现代 ArangoDB 中,这需要得到 --javascript.allow-admin-execute 的允许,否则执行将被拒绝。