如何从Heroku调度程序运行mongo脚本? [英] How to run a mongo script from Heroku scheduler?

查看:90
本文介绍了如何从Heroku调度程序运行mongo脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的mongo数据库实现了一个javascript脚本.该脚本称为 getMetrics.js ,我可以通过在计算机上运行 mongo getMetrics.js 来执行该脚本.

I have implemented a javascript script for my mongo database. This script is called getMetrics.js and I am able to execute it by running: mongo getMetrics.js from my computer.

现在,我想每天自动执行一次该脚本.为此,我创建了一个Heroku应用,并向其添加了Scheduler加载项( https://devcenter.heroku.com/articles/scheduler ).

Now I want to automatically execute that script one time per day. To do so, I have created a Heroku app and I added to it the scheduler add-on (https://devcenter.heroku.com/articles/scheduler).

我的主要问题是,要运行,我的任务将执行命令"mongo getMetrics.js",但由于未在Heroku应用程序中安装mongo命令而失败.

My main problem is that in order to be run, my task will execute the command "mongo getMetrics.js" and it will failed because I don't have mongo command installed in my Heroku app.

如何从Heroku运行此脚本?

How can I run this script from Heroku?

非常感谢您的帮助.

推荐答案

在类似情况下,我执行了以下操作:

I did the below in a similar case:

  1. 下载适用于Linux的mongodb https://www.mongodb.com/download-center#community
  2. bin文件夹包含mongo二进制文件
  3. 在您的Heroku实例中使该二进制文件可用(例如,如果您的git repo配置了Heroku,则请在脚本旁边检入该二进制文件

[确保您保存此二进制文件的文件夹在路径中,安全路径将在/bin内]

[Make sure the folder you are keeping this binary is in the path, safe path will be inside /bin]

这篇关于如何从Heroku调度程序运行mongo脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆