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

f4t66c6m  于 2022-12-09  发布在  Go
关注(0)|答案(1)|浏览(135)

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

cs7cruho

cs7cruho1#

由于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的允许,否则执行将被拒绝。

相关问题