Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing variables to .ini config file #23

Closed
BDuelz opened this issue Apr 24, 2013 · 3 comments
Closed

Passing variables to .ini config file #23

BDuelz opened this issue Apr 24, 2013 · 3 comments

Comments

@BDuelz
Copy link

BDuelz commented Apr 24, 2013

My config file makes use of variables like so:

sqlalchemy.url = postgresql+psycopg2://%(db_user)s:%(db_pass)s@127.0.0.1/%(db_name)s

And I pass them along like so:

pserve production.ini db_user=user db_pass=pass db_name=name

How can I pass these variables along using pceleryd?

@saschagottfried
Copy link

pyramid_celery.commands.CommandMixin is using pyramid.paster.bootstrap to load wsgi application from PasteDeploy config file. The current version does not pass through additional commandline arguments following config_uri to the bootstrap call.

That matters

Excerpt from docs
options Is passed to get_app for use as variable assignments like {'http_port': 8080} and then use %(http_port)s in the config file.

I changed a single line - the call to pyramid.paster.bootstrap

pyramid_celery.commands.init.py

from __future__ import absolute_import

import sys

from pyramid.paster import bootstrap
from celery.app import default_app


class CommandMixin(object):
    preload_options = ()

    def setup_app_from_commandline(self, argv):
        if len(argv) < 2:
            print >> sys.stderr, 'No configuration file specified.'
            sys.exit(1)
        bootstrap(config_uri=argv[1], options=argv[2:])
        self.app = default_app
        return argv[:1] + argv[2:]

@sontek
Copy link
Owner

sontek commented Dec 28, 2014

The previous solution doesn't work anymore because we are deprecating the p* commands. I'm thinking the new api will be:

celery -A pyramid_celery.celery_app --ini-var database=postgres, user=sontek

I wanted to support multiple --ini-var calls but there is a bug in celery currently that breaks this. PR here:

celery/celery#2435

@sontek
Copy link
Owner

sontek commented Dec 28, 2014

Added support for this in b946494

@sontek sontek closed this as completed Dec 28, 2014
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

No branches or pull requests

3 participants