diff --git a/.github/workflows/get_context.yml b/.github/workflows/get_context.yml index 94e61fa..b3f5298 100644 --- a/.github/workflows/get_context.yml +++ b/.github/workflows/get_context.yml @@ -32,7 +32,7 @@ jobs: path: artifacts - name: Get Directory structure run: ls -lR - - run: python find_posts.py --lock-hours=0 --access-token=${{ secrets.ACCESS_TOKEN }} --server=${{ vars.MASTODON_SERVER }} --reply-interval-in-hours=${{ vars.REPLY_INTERVAL_IN_HOURS || 0 }} --home-timeline-length=${{ vars.HOME_TIMELINE_LENGTH || 0 }} --max-followings=${{ vars.MAX_FOLLOWINGS || 0 }} --user=${{ vars.USER }} --max-followers=${{ vars.MAX_FOLLOWERS || 0 }} --http-timeout=${{ vars.HTTP_TIMEOUT || 5 }} --max-follow-requests=${{ vars.MAX_FOLLOW_REQUESTS || 0 }} + - run: python find_posts.py --lock-hours=0 --access-token=${{ secrets.ACCESS_TOKEN }} --server=${{ vars.MASTODON_SERVER }} --reply-interval-in-hours=${{ vars.REPLY_INTERVAL_IN_HOURS || 0 }} --home-timeline-length=${{ vars.HOME_TIMELINE_LENGTH || 0 }} --max-followings=${{ vars.MAX_FOLLOWINGS || 0 }} --user=${{ vars.USER }} --max-followers=${{ vars.MAX_FOLLOWERS || 0 }} --http-timeout=${{ vars.HTTP_TIMEOUT || 5 }} --max-follow-requests=${{ vars.MAX_FOLLOW_REQUESTS || 0 }} --finished-callback=${{ vars.FINISHED_CALLBACK }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: diff --git a/README.md b/README.md index 107c64d..02a5104 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Please see below for a list of configuration options. | `MAX_FOLLOW_REQUESTS` | `--max-follow-requests` | No | Provide to backfill profiles for the API key owner's most recent pending follow requests. Determines how many of your last follow requests you want to backfill. (An integer number, e.g. `80`.). Requires an access token with `read:follows` scope. | `HTTP_TIMEOUT` | `--http-timeout` | No | The timeout for any HTTP requests to the Mastodon API in seconds. Defaults to `5`. | -- | `--lock-hours` | No | Determines after how many hours a lock file should be discarded. Not relevant when running the script as GitHub Action, as concurrency is prevented using a different mechanism. +| `FINISHED_CALLBACK` | `--finished-callback` | No | Optionally provide a callback URL that will be called when processing is finished. This can be used for 'dead man switch' monitoring of cron jobs, for example via healthchecks.io. #### Required Access Token Scopes diff --git a/find_posts.py b/find_posts.py index 2d6c48b..9111a1f 100644 --- a/find_posts.py +++ b/find_posts.py @@ -23,6 +23,7 @@ argparser.add_argument('--max-followers', required = False, type=int, default=0, argparser.add_argument('--max-follow-requests', required = False, type=int, default=0, help="Backfill posts of the API key owners pending follow requests. We'll backfill at most this many requester's posts") argparser.add_argument('--http-timeout', required = False, type=int, default=5, help="The timeout for any HTTP requests to your own, or other instances.") argparser.add_argument('--lock-hours', required = False, type=int, default=24, help="The lock timeout in hours.") +argparser.add_argument('--finished-callback', required = False, default=None, help="Provide a callback url that will be pinged when processing is complete. You can use this for 'dead man switch' monitoring of your task") def pull_context( server, @@ -759,6 +760,12 @@ if __name__ == "__main__": os.remove(LOCK_FILE) + if(arguments.finished_callback != None): + try: + get(arguments.finished_callback) + except Exception as ex: + log(f"Error getting callback url: {ex}") + log(f"Processing finished in {datetime.now() - start}.") except Exception as ex: