【发布时间】:2016-09-23 21:34:17
【问题描述】:
我需要从 Foxx 应用程序中执行一个二进制库 (ffmpeg)。我看到有一个内置的 child_process 模块,但它没有像 Node.js 那样的 exec 方法。还有其他方法吗?
提前致谢
【问题讨论】:
我需要从 Foxx 应用程序中执行一个二进制库 (ffmpeg)。我看到有一个内置的 child_process 模块,但它没有像 Node.js 那样的 exec 方法。还有其他方法吗?
提前致谢
【问题讨论】:
由于 foxx 是同步的,我只能建议不要直接从 foxx 执行此操作。转码过程需要时间,您不希望为此阻塞数据库资源。
您应该异步执行此操作,即在节点进程中。
如果您想了解生成过程的工作原理,可以在我们的单元测试套件中找到:
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 允许,否则执行将被拒绝。
【讨论】: