1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
0bin/docs/.build/html/en/using_supervisor.html

174 lines
7.1 KiB
HTML
Raw Normal View History

<!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>Using supervisor &mdash; 0bin 0.1 documentation</title>
2015-05-10 20:53:55 +03:00
<link rel="stylesheet" href="../_static/classic.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.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="0bin 0.1 documentation" href="../index.html" />
<link rel="next" title="Theming" href="theming.html" />
<link rel="prev" title="Nginx setup" href="nginx_install.html" />
</head>
2015-05-10 20:53:55 +03:00
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<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="theming.html" title="Theming"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="nginx_install.html" title="Nginx setup"
accesskey="P">previous</a> |</li>
2015-05-10 20:53:55 +03:00
<li class="nav-item nav-item-0"><a href="../index.html">0bin 0.1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
2015-05-10 20:53:55 +03:00
<div class="body" role="main">
<div class="section" id="using-supervisor">
<h1>Using supervisor<a class="headerlink" href="#using-supervisor" title="Permalink to this headline"></a></h1>
<p>Supervisor is a very nice way to manage you Python processes. We won&#8217;t cover
the setup (which is just apt-get install supervisor or pip install supervisor
most of the time), but here is a quick overview on how to use it.</p>
<p>Create a configuration file named supervisor.ini:</p>
2015-05-10 20:53:55 +03:00
<div class="highlight-python"><div class="highlight"><pre>[unix_http_server]
file=/tmp/supervisor.sock;
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock;
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[supervisord]
logfile=/tmp/zerobin.log
logfile_maxbytes=50MB
logfile_backups=2
loglevel=trace
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=zerobin
[program:zerobin]
command=/path/to/zerobin/zerobin.py --port 80 --compressed-static
directory=/path/to/zerobin/
2015-05-10 20:53:55 +03:00
environment=PYTHONPATH=&#39;/path/to/zerobin/&#39;
user=zerobin
autostart=true
2015-05-10 20:53:55 +03:00
autorestart=true
</pre></div>
</div>
<p>The 4 first entries are just boiler plate to get you started, you can copy
them verbatim.</p>
<p>The last one define one (you can have many) process supervisor should manage.</p>
<p>It means it will run the command:</p>
2015-05-10 20:53:55 +03:00
<div class="highlight-python"><div class="highlight"><pre>/path/to/zerobin/zerobin.py --port 80 --compressed-static
</pre></div>
</div>
<p>In the directory, with the environnement and the user you defined.</p>
<p>This command will be ran as a daemon, in the background.</p>
<p><cite>autostart</cite> and <cite>autorestart</cite> just make it fire and forget: the site will always be
running, even it crashes temporarly or if you retart the machine.</p>
<p>The first time you run supervisor, pass it the configuration file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">supervisord</span> <span class="o">-</span><span class="n">c</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">supervisor</span><span class="o">.</span><span class="n">ini</span>
</pre></div>
</div>
<p>Then you can manage the process by running:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">supervisorctl</span> <span class="o">-</span><span class="n">c</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">supervisor</span><span class="o">.</span><span class="n">ini</span>
</pre></div>
</div>
<p>It will start a shell from were you can start/stop/restart the service</p>
<p>You can read all errors that might occurs from /tmp/zerobin.log.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If you installed zerobin in a virtualenv, you may set the command
to run directly from it:</p>
2015-05-10 20:53:55 +03:00
<div class="last highlight-python"><div class="highlight"><pre>command=/path/to/virtualenv/bin/zerobin --port 80 --compressed-static
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
2015-05-10 20:53:55 +03:00
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="nginx_install.html"
title="previous chapter">Nginx setup</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="theming.html"
title="next chapter">Theming</a></p>
2015-05-10 20:53:55 +03:00
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/en/using_supervisor.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<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>
2015-05-10 20:53:55 +03:00
<div class="related" role="navigation" aria-label="related navigation">
<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="theming.html" title="Theming"
>next</a> |</li>
<li class="right" >
<a href="nginx_install.html" title="Nginx setup"
>previous</a> |</li>
2015-05-10 20:53:55 +03:00
<li class="nav-item nav-item-0"><a href="../index.html">0bin 0.1 documentation</a> &raquo;</li>
</ul>
</div>
2015-05-10 20:53:55 +03:00
<div class="footer" role="contentinfo">
&copy; Copyright 2012, Sam et Max.
2015-05-10 20:53:55 +03:00
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.1.
</div>
</body>
</html>