You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2>start-stop-daemon<aclass="headerlink" href="#start-stop-daemon" title="Permalink to this headline">¶</a></h2>
67
+
<h2><aclass="toc-backref" href="#id2">start-stop-daemon</a><aclass="headerlink" href="#start-stop-daemon" title="Permalink to this headline">¶</a></h2>
Copy file name to clipboardExpand all lines: cookbook/tasks.html
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -54,8 +54,13 @@ <h3>Navigation</h3>
54
54
55
55
<divclass="section" id="creating-tasks">
56
56
<h1>Creating Tasks<aclass="headerlink" href="#creating-tasks" title="Permalink to this headline">¶</a></h1>
57
+
<divclass="contents local topic" id="contents">
58
+
<ulclass="simple">
59
+
<li><aclass="reference external" href="#ensuring-a-task-is-only-executed-one-at-a-time" id="id1">Ensuring a task is only executed one at a time</a></li>
<h2>Ensuring a task is only executed one at a time<aclass="headerlink" href="#ensuring-a-task-is-only-executed-one-at-a-time" title="Permalink to this headline">¶</a></h2>
63
+
<h2><aclass="toc-backref" href="#id1">Ensuring a task is only executed one at a time</a><aclass="headerlink" href="#ensuring-a-task-is-only-executed-one-at-a-time" title="Permalink to this headline">¶</a></h2>
59
64
<p>You can accomplish this by using a lock.</p>
60
65
<p>In this example we’ll be using the cache framework to set a lock that is
<li><aclass="reference external" href="#setting-up-rabbitmq" id="id3">Setting up RabbitMQ</a></li>
61
+
<li><aclass="reference external" href="#installing-rabbitmq-on-os-x" id="id4">Installing RabbitMQ on OS X</a><ul>
62
+
<li><aclass="reference external" href="#configuring-the-system-hostname" id="id5">Configuring the system hostname</a></li>
63
+
<li><aclass="reference external" href="#starting-stopping-the-rabbitmq-server" id="id6">Starting/Stopping the RabbitMQ server</a></li>
64
+
</ul>
65
+
</li>
66
+
</ul>
67
+
</div>
57
68
<divclass="section" id="installing-rabbitmq">
58
-
<h2>Installing RabbitMQ<aclass="headerlink" href="#installing-rabbitmq" title="Permalink to this headline">¶</a></h2>
69
+
<h2><aclass="toc-backref" href="#id2">Installing RabbitMQ</a><aclass="headerlink" href="#installing-rabbitmq" title="Permalink to this headline">¶</a></h2>
59
70
<p>See <aclass="reference external" href="http://www.rabbitmq.com/install.html">Installing RabbitMQ</a> over at RabbitMQ’s website. For Mac OS X
60
71
see <aclass="reference external" href="#installing-rabbitmq-on-os-x">Installing RabbitMQ on OS X</a>.</p>
61
72
</div>
62
73
<divclass="section" id="setting-up-rabbitmq">
63
-
<h2>Setting up RabbitMQ<aclass="headerlink" href="#setting-up-rabbitmq" title="Permalink to this headline">¶</a></h2>
74
+
<h2><aclass="toc-backref" href="#id3">Setting up RabbitMQ</a><aclass="headerlink" href="#setting-up-rabbitmq" title="Permalink to this headline">¶</a></h2>
64
75
<p>To use celery we need to create a RabbitMQ user, a virtual host and
@@ -72,7 +83,7 @@ <h2>Setting up RabbitMQ<a class="headerlink" href="#setting-up-rabbitmq" title="
72
83
<p>See the RabbitMQ <aclass="reference external" href="http://www.rabbitmq.com/admin-guide.html">Admin Guide</a> for more information about <aclass="reference external" href="http://www.rabbitmq.com/admin-guide.html#access-control">access control</a>.</p>
<h2>Installing RabbitMQ on OS X<aclass="headerlink" href="#installing-rabbitmq-on-os-x" title="Permalink to this headline">¶</a></h2>
86
+
<h2><aclass="toc-backref" href="#id4">Installing RabbitMQ on OS X</a><aclass="headerlink" href="#installing-rabbitmq-on-os-x" title="Permalink to this headline">¶</a></h2>
76
87
<p>The easiest way to install RabbitMQ on Snow Leopard is using <aclass="reference external" href="http://github.com/mxcl/homebrew/">Homebrew</a>; the new
77
88
and shiny package management system for OS X.</p>
78
89
<p>In this example we’ll install homebrew into <ttclass="docutils literal"><spanclass="pre">/lol</span></tt>, but you can
@@ -97,7 +108,7 @@ <h2>Installing RabbitMQ on OS X<a class="headerlink" href="#installing-rabbitmq-
<h3>Configuring the system hostname<aclass="headerlink" href="#configuring-the-system-hostname" title="Permalink to this headline">¶</a></h3>
111
+
<h3><aclass="toc-backref" href="#id5">Configuring the system hostname</a><aclass="headerlink" href="#configuring-the-system-hostname" title="Permalink to this headline">¶</a></h3>
101
112
<p>If you’re using a DHCP server that is giving you a random hostname, you need
102
113
to permanently configure the hostname. This is because RabbitMQ uses the hostname
103
114
to communicate with nodes.</p>
@@ -127,7 +138,7 @@ <h3>Configuring the system hostname<a class="headerlink" href="#configuring-the-
127
138
then RabbitMQ will try to use <ttclass="docutils literal"><spanclass="pre">rabbit@23</span></tt>, which is an illegal hostname.</p>
<h3>Starting/Stopping the RabbitMQ server<aclass="headerlink" href="#starting-stopping-the-rabbitmq-server" title="Permalink to this headline">¶</a></h3>
141
+
<h3><aclass="toc-backref" href="#id6">Starting/Stopping the RabbitMQ server</a><aclass="headerlink" href="#starting-stopping-the-rabbitmq-server" title="Permalink to this headline">¶</a></h3>
<li><aclass="reference external" href="#running-the-celery-worker-server" id="id3">Running the celery worker server</a></li>
62
+
<li><aclass="reference external" href="#executing-the-task" id="id4">Executing the task</a></li>
63
+
</ul>
64
+
</div>
57
65
<divclass="section" id="creating-a-simple-task">
58
-
<h2>Creating a simple task<aclass="headerlink" href="#creating-a-simple-task" title="Permalink to this headline">¶</a></h2>
66
+
<h2><aclass="toc-backref" href="#id1">Creating a simple task</a><aclass="headerlink" href="#creating-a-simple-task" title="Permalink to this headline">¶</a></h2>
59
67
<p>In this example we are creating a simple task that adds two
60
68
numbers. Tasks are defined in a normal python module. The module can
61
69
be named whatever you like, but the convention is to call it
@@ -76,7 +84,7 @@ <h2>Creating a simple task<a class="headerlink" href="#creating-a-simple-task" t
<h2>Running the celery worker server<aclass="headerlink" href="#running-the-celery-worker-server" title="Permalink to this headline">¶</a></h2>
128
+
<h2><aclass="toc-backref" href="#id3">Running the celery worker server</a><aclass="headerlink" href="#running-the-celery-worker-server" title="Permalink to this headline">¶</a></h2>
121
129
<p>To test we will run the worker server in the foreground, so we can
<h2>Executing the task<aclass="headerlink" href="#executing-the-task" title="Permalink to this headline">¶</a></h2>
144
+
<h2><aclass="toc-backref" href="#id4">Executing the task</a><aclass="headerlink" href="#executing-the-task" title="Permalink to this headline">¶</a></h2>
137
145
<p>Whenever we want to execute our task, we can use the <ttclass="docutils literal"><spanclass="pre">delay</span></tt> method
138
146
of the task class.</p>
139
147
<p>This is a handy shortcut to the <ttclass="docutils literal"><spanclass="pre">apply_async</span></tt> method which gives
<h3>Downloading and installing from source<aclass="headerlink" href="#downloading-and-installing-from-source" title="Permalink to this headline">¶</a></h3>
257
+
<h3><aclass="toc-backref" href="#id6">Downloading and installing from source</a><aclass="headerlink" href="#downloading-and-installing-from-source" title="Permalink to this headline">¶</a></h3>
245
258
<p>Download the latest version of <ttclass="docutils literal"><spanclass="pre">celery</span></tt> from
<h3>Using the development version<aclass="headerlink" href="#using-the-development-version" title="Permalink to this headline">¶</a></h3>
268
+
<h3><aclass="toc-backref" href="#id7">Using the development version</a><aclass="headerlink" href="#using-the-development-version" title="Permalink to this headline">¶</a></h3>
256
269
<p>You can clone the repository by doing the following:</p>
0 commit comments