【问题标题】:GAE runs commented out cron task?GAE 运行注释掉的 cron 任务?
【发布时间】:2018-01-13 14:41:19
【问题描述】:

我目前参与的项目在 GAE 上托管其应用程序。昨晚深夜,我使用 cron.yaml 将我们的应用程序部署到 QA 服务器(也托管在 GAE 上),该 cron.yaml 有一个注释掉的 cron 作业。

部署完成后立即运行 cron 任务。对此有什么解释吗?

下面是相关的 cron.yaml 和日志。在任何给定时间,我们只有一个 qa 后端实例。

我们的堆栈是 flask/python 和 angular 前端。我的机器:macOS Sierra 10.12.1,GAE init v.4.0.1

cron.yaml:

日志:

gulpfile:
`

var $, gulp, minimist;

gulp      = require('gulp-help')(require('gulp'));
minimist  = require('minimist');
$         = require('gulp-load-plugins')();

gulp.task('deploy', 'Deploy project to Google App Engine.', function() {
  var k, options, options_str;
  options = minimist(process.argv);
  delete options['_'];
  options_str = '--skip_sdk_update_check';
  for (k in options) {
    if (options[k] === true) {
      options[k] = '';
    }
    options_str += k.length > 1 ? " --" + k + " " + options[k] : " -" + k + " " + options[k];
  }
  return gulp.src('run.py').pipe($.start([{
    match: /run.py$/,
    cmd: "appcfg.py update main " + options_str
  }]));
});

gulp.task('server', 'Start the local server. Available options:\n -o 
HOST  - the host to start the dev_appserver.py\n -p PORT  - the port 
to start the dev_appserver.py\n -a="..." - all following args are 
passed to dev_appserver.py\n', function() {
  var argv, k, known_options, options, options_str;
  argv = process.argv.slice(2);
  known_options = {
    "default": {
      p: '',
      o: '',
      a: ''
    }
  };
  options = minimist(argv, known_options);
  options_str = '-s';
  for (k in known_options["default"]) {
    if (options[k]) {
      if (k === 'a') {
        options_str += " --appserver-args \"" + options[k] + "\"";
      } else {
        options_str += " -" + k + " " + options[k];
      }
    }
  }
   return gulp.src('run.py').pipe($.start([
     {
      match: /run.py$/,
      cmd: "python run.py " + options_str
    }
  ]));
});

`

谢谢!

【问题讨论】:

  • 您在开发者控制台中看到 cron 作业了吗?您在部署之前启用了 cron 吗?
  • 控制台中没有出现,我部署的时候也没有开启。
  • 这可能是对该 URL 的手动请求吗?
  • payload 表明请求来自 cron。
  • 你是如何部署的?

标签: python google-app-engine flask cron google-cloud-platform


【解决方案1】:

因为我不知道你的 gulp 任务是什么样子,所以在这里拍一张传单,但我怀疑它正在发出以下部署命令:

appcfg.py update app.yaml

不更新索引或 cron 作业(即:不引用文件 cron.yaml 或 index.yaml)。

相反,您需要更新要使用的任务:

appcfg.py update .

然后它将执行必要的操作。见here

注意:现在最好使用 gcloud:

gcloud app deploy ...

【讨论】:

  • 这在我们的 gulpfile 中没有被调用。
  • 您可以将 gulpfile 添加到问题中吗?
  • 添加了 gulpfile
  • 太棒了;您正在调用“appcfg.py update main”;所以下一个问题是:哪些 yaml 文件在您的“主”目录中,您的“cron.yaml”文件在哪里?如果 cron.yaml 不在 main 中,则此 gulp 任务不会部署它。
  • 它与其余的 yamls 是主要的
猜你喜欢
  • 2017-02-28
  • 2021-09-01
  • 2012-02-22
  • 2014-11-30
  • 1970-01-01
  • 1970-01-01
  • 2015-12-23
  • 2011-07-28
  • 2011-07-27
相关资源
最近更新 更多