Source

celery-pylons / docs / _build / html / getting-started / first-steps-with-pylons.html

Full commit


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>First steps with celery-pylons &mdash; celery-pylons v0.0.1 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="celery-pylons v0.0.1 documentation" href="../index.html" />
    <link rel="up" title="Getting Started wth celery-pylons" href="index.html" />
    <link rel="next" title="changelog" href="../changelog.html" />
    <link rel="prev" title="Getting Started wth celery-pylons" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../changelog.html" title="changelog"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Getting Started wth celery-pylons"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">celery-pylons v0.0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">Getting Started wth celery-pylons</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="first-steps-with-celery-pylons">
<span id="first-steps-ref"></span><h1>First steps with celery-pylons<a class="headerlink" href="#first-steps-with-celery-pylons" title="Permalink to this headline"></a></h1>
<div class="section" id="configuring-your-pylons-project-to-use-celery">
<h2>Configuring your Pylons project to use Celery<a class="headerlink" href="#configuring-your-pylons-project-to-use-celery" title="Permalink to this headline"></a></h2>
<p>There are a few simple steps to integrate Celery into your Pylons
project.</p>
<blockquote>
<ol class="arabic">
<li><p class="first">Install celery-pylons (<em>see</em> <a class="reference internal" href="../introduction.html#installation"><em>Installation</em></a>)</p>
</li>
<li><p class="first">Add the following to your <tt class="docutils literal"><span class="pre">development.ini</span></tt> file in the section <tt class="docutils literal"><span class="pre">[app:main]</span></tt> <a class="footnote-reference" href="#a" id="id1">[1]</a>:</p>
<div class="highlight-python"><pre>broker.host = localhost
broker.port = 5672
broker.user = [user setup with rabbitmqctl command]
broker.password = [user setup with rabbitmqctl command]
broker.vhost = [user setup with rabbitmqctl command]
celery.result.backend = amqp
celery.result.dburi = amqp://
celery.imports = [list of classes: app.tasks.module]</pre>
</div>
</li>
<li><p class="first">That&#8217;s it! Give it a try <a class="footnote-reference" href="#b" id="id2">[2]</a>:</p>
<div class="highlight-python"><pre>$ paster celeryd development.ini</pre>
</div>
</li>
</ol>
</blockquote>
<p><strong>Please Note:</strong></p>
<table class="docutils footnote" frame="void" id="a" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Application label may vary depending on Pylons setup.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="b" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td><p class="first">Depending on your Pylons setup, you may need to append
<tt class="docutils literal"><span class="pre">#_your_app_name_</span></tt> to the <tt class="docutils literal"><span class="pre">development.ini</span></tt> paster config file
argument:</p>
<div class="last highlight-python"><pre>$ paster celeryd development.ini#foo</pre>
</div>
</td></tr>
</tbody>
</table>
</div>
<div class="section" id="running-the-celery-worker-server">
<h2>Running the celery worker server<a class="headerlink" href="#running-the-celery-worker-server" title="Permalink to this headline"></a></h2>
<p>Assuming you&#8217;ve got your virtualenv activated:</p>
<div class="highlight-python"><pre>$ paster celeryd -B</pre>
</div>
<p>However, in production you&#8217;ll probably want to run the work in the
background as a daemon. You&#8217;ll need to rely on the tools provided by
your platform. See the celery docs <a class="reference external" href="http://celeryq.org/docs/cookbook/daemonizing.html">Running Celery as a Daemon</a>.</p>
<p>For a complete listing of the command line optinos available, use the help command:</p>
<div class="highlight-python"><pre>$ paster help</pre>
</div>
</div>
<div class="section" id="defining-and-executing-tasks">
<h2>Defining and executing tasks<a class="headerlink" href="#defining-and-executing-tasks" title="Permalink to this headline"></a></h2>
<p><strong>Please note:</strong> All the tasks have to be stored in a real module, they can&#8217;t
be defined in the python shell or ipython/bpython. This is because the celery
worker server needs access to the task function to be able to run it.</p>
<p>Put tasks in the <tt class="docutils literal"><span class="pre">tasks</span></tt> module of your Pylons application. The
worker server will <strong>not</strong> automatically load your tasks. They must be
listed in your <tt class="docutils literal"><span class="pre">development.ini</span></tt> file.</p>
<p>see <a class="reference internal" href="#configuring-your-pylons-project-to-use-celery">Configuring your Pylons project to use Celery</a> for more information.</p>
</div>
<div class="section" id="where-to-go-from-here">
<h2>Where to go from here<a class="headerlink" href="#where-to-go-from-here" title="Permalink to this headline"></a></h2>
<p>To learn more you should read the <a class="reference external" href="http://celeryproject.org/docs/userguide/">Celery User Guide</a>, and the <a class="reference external" href="http://celeryproject.org/docs/">Celery Documentation</a>.</p>
<p>Want to learn more about RabbitMQ? Check out their <a class="reference external" href="http://www.rabbitmq.com/how.html">getting started</a> page for a plethora of information.</p>
<p>Or, take a look at RabbitMQ&#8217;s <a class="reference external" href="http://www.rabbitmq.com/man/rabbitmqctl.1.man.html/">configuration</a> page for more details on RabbitMQ configuration</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">First steps with celery-pylons</a><ul>
<li><a class="reference internal" href="#configuring-your-pylons-project-to-use-celery">Configuring your Pylons project to use Celery</a></li>
<li><a class="reference internal" href="#running-the-celery-worker-server">Running the celery worker server</a></li>
<li><a class="reference internal" href="#defining-and-executing-tasks">Defining and executing tasks</a></li>
<li><a class="reference internal" href="#where-to-go-from-here">Where to go from here</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">Getting Started wth celery-pylons</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../changelog.html"
                        title="next chapter">changelog</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/getting-started/first-steps-with-pylons.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../changelog.html" title="changelog"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Getting Started wth celery-pylons"
             >previous</a> |</li>
        <li><a href="../index.html">celery-pylons v0.0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" >Getting Started wth celery-pylons</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2010, Ian Schenck, Jonathan Stasiak.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.4.
    </div>
  </body>
</html>