简体   繁体   English

在grunt构建之后“heroku运行fileName”

[英]“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... 这是我特意尝试过的......

  1. Added bin/refresh before Grunt build (refresh code below) 在Grunt构建之前添加了bin / refresh(下面的刷新代码)
  2. Added bin/refresh directly into the Dist folder after grunt build 在grunt构建之后,将bin / refresh直接添加到Dist文件夹中
  3. Tried heroku run anyFile after git push heroku master with both attempts 经过git push heroku master尝试后,尝试heroku运行anyFile

```````` ````````

#!/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: 步骤应该是这样的:

  1. grunt build
  2. cp refresh dist/refresh
  3. cd dist && git commit
  4. git push heroku master
  5. 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 lsheroku 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM