1. <legend id='BUKe4'><style id='BUKe4'><dir id='BUKe4'><q id='BUKe4'></q></dir></style></legend>
    2. <small id='BUKe4'></small><noframes id='BUKe4'>

    3. <i id='BUKe4'><tr id='BUKe4'><dt id='BUKe4'><q id='BUKe4'><span id='BUKe4'><b id='BUKe4'><form id='BUKe4'><ins id='BUKe4'></ins><ul id='BUKe4'></ul><sub id='BUKe4'></sub></form><legend id='BUKe4'></legend><bdo id='BUKe4'><pre id='BUKe4'><center id='BUKe4'></center></pre></bdo></b><th id='BUKe4'></th></span></q></dt></tr></i><div id='BUKe4'><tfoot id='BUKe4'></tfoot><dl id='BUKe4'><fieldset id='BUKe4'></fieldset></dl></div>
      <tfoot id='BUKe4'></tfoot>

        • <bdo id='BUKe4'></bdo><ul id='BUKe4'></ul>

        如何从节点在 Heroku 上运行可执行文件,在本地工

        时间:2023-08-03

          • <bdo id='ifN2j'></bdo><ul id='ifN2j'></ul>
          • <small id='ifN2j'></small><noframes id='ifN2j'>

                <tfoot id='ifN2j'></tfoot>

                  <tbody id='ifN2j'></tbody>
                <legend id='ifN2j'><style id='ifN2j'><dir id='ifN2j'><q id='ifN2j'></q></dir></style></legend>

                1. <i id='ifN2j'><tr id='ifN2j'><dt id='ifN2j'><q id='ifN2j'><span id='ifN2j'><b id='ifN2j'><form id='ifN2j'><ins id='ifN2j'></ins><ul id='ifN2j'></ul><sub id='ifN2j'></sub></form><legend id='ifN2j'></legend><bdo id='ifN2j'><pre id='ifN2j'><center id='ifN2j'></center></pre></bdo></b><th id='ifN2j'></th></span></q></dt></tr></i><div id='ifN2j'><tfoot id='ifN2j'></tfoot><dl id='ifN2j'><fieldset id='ifN2j'></fieldset></dl></div>
                  本文介绍了如何从节点在 Heroku 上运行可执行文件,在本地工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的第一个 SE 问题.通常我可以通过这个很棒的网站很容易地找到任何问题的答案,但不幸的是,在这种情况下,无论是在这里还是在其他地方,我都找不到任何我正在寻找的东西.让我解释一下问题:

                  This is my first SE question. Usually I can find an answer to anything fairly easily through this great website, but unfortunately on this occasion I can't find anything on what I am looking for, either here or elsewhere. Let me explain the problem:

                  我编写了一个 C++ 程序来进行一些数值计算.它接受命令行参数并写入标准输出,并且在我运行 OSX 的系统上运行良好.

                  I have written a C++ program to do some numerical computations. It takes command line arguments and writes to stdout and works fine on my system running OSX.

                  我想在线托管它,让我的同行更轻松地试用它,因此我编写了一些 Node.js 和 Express 代码来从表单中获取输入并将其作为命令行参数提供给可执行文件.然后我按以下方式执行名为factoriser"的二进制文件:

                  I want to host this online for my peers to try it out more easily, and so I wrote some Node.js and Express code to take an input from a form and give that as a command line argument to the executable. I then execute the binary called 'factoriser' in the following way:

                  const exec = require('child_process').exec;
                  app.post('/', function (req, res) {
                      var input = req.body.numberinput; //Number entered on the webpage
                  
                      const child = exec('./numericcomp ' + input, {timeout: 20000}, function(error, stdout, stderr) {
                          //Code here writes stdout to the page
                      }
                  }
                  

                  以上在我的本地机器上完美运行,但是当我将它部署到 Heroku 然后尝试输入时(这里我尝试了 2131),我得到一个错误:

                  The above works perfectly on my local machine but when I deploy it to Heroku and then try an input (here I tried 2131) I get an error of:

                  Error: Command failed: ./numericcomp 2131 ./numericcomp: 3: ./numericcomp: Syntax error: word unexpected (expecting ")")
                  

                  给 exec 中的回调函数.

                  that is given to the callback in exec.

                  所以我真的不知道该怎么办,问题是 Heroku 没有正确运行可执行文件.我对 Heroku 的工作原理不是特别了解,我已经阅读了有关 buildpack 等的信息,但仅执行二进制文件似乎是一个非常复杂的过程.是不是因为我只有一个dyno,不能运行子进程?

                  So I really don't know what to do, the issue is that Heroku just isn't running the executable properly. I am not particularly knowledgable about how Heroku works, I have read through info on buildpacks etc. but it seems a very complicated process just to execute a binary. Is it because I only have one dyno and it can't run the child process?

                  如果有人能在这里为我指明正确的方向,我将不胜感激,看来我已经完成了所有的努力,但无法克服最后的障碍.

                  I would be very grateful if someone could point me in the right direction here, it seems I have done all the hard work but can't get over the final hurdle.

                  推荐答案

                  好的,我已经开始工作了,很多人可能对此感兴趣,所以我会发布我是如何做到的.

                  Ok, I have got it to work, this may be of interest to many so I will post how I did it.

                  问题是 Heroku 的架构与我机器上的架构不同,因此编译后的程序根本无法在 Heroku 上运行.为了解决这个问题,我创建了一个 makefile 来编译 C++ 源代码并使用

                  The problem was that Heroku's architecture is not the same as that on my machine and hence the compiled program simply would not run on Heroku. To get around this I created a makefile to compile the C++ source code and pushed this to Heroku using

                  $ git push heroku master
                  

                  然后

                  $ heroku run bash
                  

                  它实质上设置了一个可以访问您的 Heroku 实例的 bash shell.

                  which essentially sets up a bash shell with access to your Heroku instance.

                  从这里,使用

                  $ make
                  

                  然后scp这个可执行文件回到你的本地机器然后

                  Then scp this executable back to your local machine and then

                  $ git add .
                  $ git commit -m "added working executable"
                  

                  $ git push heroku master
                  

                  然后运行的可执行文件将在 Heroku 应用程序中,并且将像在本地主机上一样运行.

                  Then the working executable will be there on the Heroku app and will run just like on local host.

                  这篇关于如何从节点在 Heroku 上运行可执行文件,在本地工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何定义递归概念? 下一篇:在 C++ 跨平台中解析 url 的简单方法?

                  相关文章

                  最新文章

                      <bdo id='nuvoP'></bdo><ul id='nuvoP'></ul>

                    <tfoot id='nuvoP'></tfoot>
                      <i id='nuvoP'><tr id='nuvoP'><dt id='nuvoP'><q id='nuvoP'><span id='nuvoP'><b id='nuvoP'><form id='nuvoP'><ins id='nuvoP'></ins><ul id='nuvoP'></ul><sub id='nuvoP'></sub></form><legend id='nuvoP'></legend><bdo id='nuvoP'><pre id='nuvoP'><center id='nuvoP'></center></pre></bdo></b><th id='nuvoP'></th></span></q></dt></tr></i><div id='nuvoP'><tfoot id='nuvoP'></tfoot><dl id='nuvoP'><fieldset id='nuvoP'></fieldset></dl></div>
                    1. <legend id='nuvoP'><style id='nuvoP'><dir id='nuvoP'><q id='nuvoP'></q></dir></style></legend>
                    2. <small id='nuvoP'></small><noframes id='nuvoP'>