Skip to content

Allow environment variables in crontab file - #47

Open
topiaruss wants to merge 3 commits into
jgorset:masterfrom
topiaruss:master
Open

Allow environment variables in crontab file#47
topiaruss wants to merge 3 commits into
jgorset:masterfrom
topiaruss:master

Conversation

@topiaruss

Copy link
Copy Markdown

I want to set environment variables, specifically DB paths, in my docker-compose.yml file.

Why?

This is the path of least resistance when you quickly want to override a setting that is closely linked to the location of the deployment, to support commands exposed by Kronos. Bear in mind that the Docker environment exists during the deployment, but not while your tasks run. So what is not captured into a settings file during deployment is relatively hard to influence later.

Here's a piece of YML, demonstrating how to set KRONOS_ENV

web:
  restart: always
  environment:
    DB_USER: postgres
    KRONOS_ENV: DB_SERVICE=myappdb1.cyweh001arg.eu-west-1.rds.amazonaws.com\nFOO=bar
  build: ./web
  expose:
    - "8000"
  links:
    - redis:redis
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - /usr/src/app/static
  command: /usr/src/app/do_run_server

The KRONOS_ENV values appear at the top of the crontab file, tagged with new breadcrumbs :

# KRONOS_ENV_BREAD_CRUMB for next
DB_SERVICE=myappdb1.cyweh001arg.eu-west-1.rds.amazonaws.com
# KRONOS_ENV_BREAD_CRUMB for next
FOO=bar
5 * * * * python manage.py my_little_command
5 * * * * python manage.py my_other_command

The entries will be removed when uninstall is invoked, and updated as the setting changes.

The settings apply to all tasks in the file.

If you accept the PR, I'll extend the doc.

Comment thread .gitignore

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory is specific to your development environment, so you should probably add it to your global ignore file and remove it from this one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair comment.

Russ Ferriday
M: +44 7429 518822
Skype: ferriday

On 7 Jan 2016, at 17:39, Johannes Gorset notifications@github.com wrote:

In .gitignore:

@@ -2,3 +2,4 @@ build
*.pyc
dist
django_kronos.egg-info
+.idea/
This directory is specific to your environment, so you should probably add it to your global ignore file and remove it from this one.


Reply to this email directly or view it on GitHub.

@jgorset

jgorset commented Jan 7, 2016

Copy link
Copy Markdown
Owner

Hey thanks, @topiaruss, and sorry for taking so long to get around to this! I think this makes sense, so I'd be happy to accept the pull request if you can find the time to document it. ✨ 🍰 ✨

@topiaruss

Copy link
Copy Markdown
Author

Thanks.
Let me conjure a little time to do that.

Russ Ferriday
M: +44 7429 518822
Skype: ferriday

On 7 Jan 2016, at 17:43, Johannes Gorset notifications@github.com wrote:

Hey thanks, @topiaruss, and sorry for taking so long to get around to this! I think this makes sense, so I'd be happy to accept the pull request if you can find the time to document it.


Reply to this email directly or view it on GitHub.

@jgorset

jgorset commented Jan 11, 2016

Copy link
Copy Markdown
Owner

Cool! I'll make a new release when you do. Maybe even v1.0!

@jgorset
jgorset force-pushed the master branch 2 times, most recently from b9400f4 to b82fde8 Compare January 11, 2016 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants