[英]“heroku run fileName” after grunt build
To learn more about heroku scheduling I read this post and built the app described in it. 要了解有关heroku调度的更多信息,请阅读此文章并构建其中描述的应用程序。 The key part of this post was when I was able to
heroku run numCheck
and the code within the numCheck file executed. 这篇文章的关键部分是当我能够
heroku run numCheck
并执行numCheck文件中的代码时 。 After testing that heroku run numCheck
worked I was able to schedule regularly occurring events in Heroku just fine. 在测试了
heroku run numCheck
工作后,我能够在Heroku中安排定期发生的事件。
I used yo angular-fullstack to create my app, Angel Insights and it's functional. 我用yo angular-fullstack来创建我的应用程序, Angel Insights ,它的功能。 However I want to add in heroku scheduling capabilities but I'm getting stuck.
但是我想添加heroku调度功能,但我遇到了困难。 My problem is that I cannot run
heroku run refresh
in the Dist folder after I've run grunt build
. 我的问题是,在运行
grunt build
后,我无法在Dist文件夹中运行heroku run refresh
。 Here's what I've tried specifically... 这是我特意尝试过的......
```````` ````````
#!/usr/bin/env node
var sendgrid = require('sendgrid')(
process.env.SENDGRID_USERNAME,
process.env.SENDGRID_PASSWORD
);
var num1 = Math.ceil(Math.random() * 100);
var num2 = Math.ceil(Math.random() * 100);
var comparator;
if (num1 > num2) {
comparator = "greater than";
} else if (num1 < num2) {
comparator = "less than";
} else {
comparator = "equal to";
}
sendgrid.send({
to: 'andrewscheuermann@gmail.com',
from: 'scheduler@tester.com',
subject: 'Num1 v Num2',
text: (num1 + ' is ' + comparator + " " + num2 + ".")
}, function(err, json) {
if (err) {
console.error(err);
}
I'm really stuck and any insights are extremely appreciated! 我真的被卡住了,任何见解都非常感激!
With the angular generators you have to be careful about it overwriting the dist
directory. 使用角度生成器,您必须小心它覆盖
dist
目录。 Each time you grunt build
you're going to start with a mostly clean dist
dir. 每次时间
grunt build
你要开始一个主要的清洁dist
目录。
The steps should be something like: 步骤应该是这样的:
grunt build
cp refresh dist/refresh
cd dist && git commit
git push heroku master
heroku run refresh
The main missing step being that you have to commit the copied file into dist
after you copy it, otherwise heroku won't get it. 主要的缺失步骤是你必须在复制后将复制的文件提交到
dist
,否则heroku将无法获取它。 You can always do heroku run ls
or heroku run bash
to see if your file is there. 您可以随时执行
heroku run ls
或heroku run bash
来查看您的文件是否存在。
After that works, you should look at your Gruntfile.js
to make sure that refresh
is copied there each time, you probably want to look at the copy
task. 在此之后,您应该查看您的
Gruntfile.js
以确保每次都复制refresh
,您可能希望查看copy
任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.