【问题标题】:Executing shell commands from a Foxx app从 Foxx 应用程序执行 shell 命令
【发布时间】:2016-09-23 21:34:17
【问题描述】:

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

提前致谢

【问题讨论】:

    标签: arangodb foxx


    【解决方案1】:

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

    【讨论】:

    • 谢谢!效果很好。我将 ffmpeg 作为守护进程运行,因此它不会阻塞 db
    • @dothebart 还有其他可用的文档吗?该链接已损坏。
    • 我已经修复了链接并添加了函数列表以及现在需要的命令行选项文档。抱歉,没有更多的官方文档。
    猜你喜欢
    • 1970-01-01
    • 2012-05-28
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 2011-02-06
    • 2015-05-01
    • 2018-07-03
    • 1970-01-01
    相关资源
    最近更新 更多