简体   繁体   English

如何让任务作为 ECS 服务的一部分运行?

[英]How do I get the tasks running as part of an ECS service?

I would like to read the tasks running on a service through aws-sdk nodejs.我想通过 aws-sdk nodejs 读取服务上运行的任务。 I tried describeServices API but there is no information about the tasks.我试过describeServices API 但没有关于任务的信息。

Tasks are running on a cluster and managed by a service.任务在集群上运行并由服务管理。 You need to use the ListTasks API to get more information about the tasks in a cluster that belong to a certain service.您需要使用 ListTasks API 来获取有关集群中属于特定服务的任务的更多信息。

The API call should look something like this: API 调用应如下所示:

var params = {
  cluster: '<cluster-name>',
  serviceName: '<service-name>'
};
ecs.listTasks(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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