Actor picture

Abort Actor Runs

mnmkng/abort-actor-runs

This actor enables aborting of all user's currently running actors with a single click or by a single API call. It will scan all actors of the user and up to 1000 of their latest runs and will abort all RUNNING and READY actors. It may also be called with an "actorIds" parameter, which is an Array listing only specific actor ids for which the runs should be aborted. By default it's set to run with 128MBs of memory to minimize compute unit usage at the expense of speed. If you need it to run faster, increase the memory limit. It also scans the user's actors sequentially to prevent API abuse. If you need even more speed, modify the source code to run concurrently, but make sure not to hit the API rate limits.

To run the code examples, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const Apify = require('apify');

// Set API token
Apify.client.setOptions({ token: '<YOUR_API_TOKEN>' });

// Prepare actor input
const input = {};

// Run the actor
const run = await Apify.call('mnmkng/abort-actor-runs', input);

// Print actor output (if any)
console.log('Output');
console.dir(run.output);

// Fetch and print actor results from the run's dataset (if any)
console.log('Results from dataset');
const dataset = await Apify.openDataset(run.defaultDatasetId, { forceCloud: true });
await dataset.forEach(async (item, index) => {
    console.log(JSON.stringify(item));
});
  • Updated
  • Last run
  • Used77 times
  • Used by6 users
Categories