nprapps/clerk

Name: clerk

Owner: NPR visuals team

Description: A cron job --> Slack webhook that posts new action from the House floor

Created: 2017-02-03 18:25:00.0

Updated: 2017-04-25 21:10:44.0

Pushed: 2017-02-03 18:52:24.0

Homepage: null

Size: 16

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

clerk

What is this?

Clerk is a cron job that posts to a Slack webhook whenever new action happens on the House floor. It pulls from the official House clerk XML feed

Assumptions

The following things are assumed to be true in this documentation.

For more details our stack, see our development environment blog post.

What's in here?

The project contains the following folders and important files:

Bootstrap the project
lerk
rtualenv clerk
install -r requirements.txt
Hide project secrets

Project secrets should never be stored in app_config.py or anywhere else in the repository. They will be leaked to the client if you do. Instead, always store passwords, keys, etc. in environment variables and document that they are needed here in the README.

Any environment variable that starts with $PROJECT_SLUG_ will be automatically loaded when app_config.get_secrets() is called.

Connecting to Slack

To connect Clerk to your Slack, you will need to create an incoming webhook and copy the webhook endpoint to an environment variable called clerk_WEBHOOK. The default server setup expects the environment variable to be placed in /etc/environment.

Setting up servers

Use the server configuration in app_config.py to set up your servers correctly. You can set the user, python version, and the folders where various pieces install.

Deploy to EC2
  1. Run fab staging master servers.setup to configure the server.
  2. Run fab staging master deploy to deploy the project to the server. Note that this will also install your crontab.
Managing cron jobs

Cron jobs are defined in the file crontab. Each task should use the run_on_server.sh shim to ensure the project's virtualenv is properly activated prior to execution. For example:

* * * ubuntu bash /home/ubuntu/apps/clerk/repository/cron.sh fab $DEPLOYMENT_TARGET cron_jobs.test >> /var/log/clerk/crontab.log 2>&1

The cron jobs themselves should be defined in fabfile/cron_jobs.py whenever possible.

To install the cronjob, run either fab staging master deploy, which will also synchronize the repo with the latest on Github, or fab staging master servers.install_crontab to simply copy the crontab on the server to etc/cron.d.

To uninstall the cronjob (a recommended practice for disabling the job), run fab staging master servers.uninstall_cronjob.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.