# swf-workflow-monitor

Python SWF workflow monitor (aka Sidecar Killa)

This application is a lightweight polling process that monitors SWF executions for a given domain and workflow name. Centrally, it kills the Fargate task in which it is running if no executions for that domain and workflow are in the `OPEN` status. It is intended to run as a sidecar container, inside a Fargate task, alongside the container running the same swf flow it is monitoring; this approach was chosen in order to reap the cost optimizations of having on-demand (rather than always-on) compute containers, while not modifying the existing swf/supervisord/garcon stack and codebase and allowing them to function as they currently do, which is a well-established, understood, and heavily relied-upon pattern.

An example might be the `prod_swf_feed_ingestion` SWF domain and `spotify_marketshare` workflow name. A Fargate task would run both containers: one running the [spotify_marketshare flow processes](https://github.com/theorchard/swf-feed-ingestion/blob/master/conf/spotify_marketshare_supervisor.conf), and one running this application, passing in `prod_swf_feed_ingestion` and `spotify_marketshare` as the value of the `SWF_MONITOR_DOMAIN` and `SWF_MONITOR_WORKFLOW_NAME` environment variables, respectively.

Some early design notes and goals can be found [here](https://docs.google.com/document/d/1U1Aw4wj6JuX31t2tXDDcvJNqjX3LNcLH0Izk-boQUrY/edit#).
