Commits

Mikhail Korobov committed 54ebac2

Draft reference docs for available fab commands

Comments (0)

Files changed (7)

docs/commands.rst

+Reference: working with server
+==============================
+
+Django
+------
+
+.. automodule:: fab_deploy.django_commands
+    :members:
+
+Virtualenv/pip
+--------------
+
+.. automodule:: fab_deploy.virtualenv
+    :members:
+
+MySQL
+-----
+
+.. automodule:: fab_deploy.mysql
+    :members:
+
+
+
+Working with crontab
+--------------------
+
+.. automodule:: fab_deploy.crontab
+    :members:
+
+Web servers
+-----------
+
+.. automodule:: fab_deploy.apache
+    :members:
+
+.. automodule:: fab_deploy.nginx
+    :members:
+
+
 
    guide
    fabfile
+   commands
    related
 
 .. toctree::

fab_deploy/apache.py

 from fab_deploy.system import aptitude_install
 
 def touch(wsgi_file=None):
-    """ Reloads source code by touching the wsgi file """
+    """ Reloads source code by touching the wsgi file. """
     if wsgi_file is None:
         wsgi_file = env.conf['ENV_DIR']+'/var/wsgi/'+env.conf['INSTANCE_NAME']+'.py'
     run('touch ' + wsgi_file)
 
 def apache_make_wsgi():
+    """ Uploads wsgi deployment script. """
     wsgi_dir = env.conf['ENV_DIR']+'/var/wsgi/'
     run('mkdir -p ' + wsgi_dir)
     file_name = env.conf['INSTANCE_NAME']+'.py'
 
 @run_as('root')
 def apache_restart():
+    """ Restarts apache using init.d script. """
     run('/etc/init.d/apache2 stop')
     run('/etc/init.d/apache2 start')
 
 
 @run_as('root')
 def apache_install():
+    """ Installs apache. """
     aptitude_install('apache2 libapache2-mod-wsgi libapache2-mod-rpaf')
     run('rm -f /etc/apache2/sites-enabled/default')
     run('rm -f /etc/apache2/sites-enabled/000-default')
 
 @run_as('root')
 def apache_make_config():
+    """ Updates apache config. """
     name = env.conf['INSTANCE_NAME']
     upload_config_template('apache.config', '/etc/apache2/sites-available/%s' % name)
     run('a2ensite %s' % name)
 
 def apache_setup():
+    """ Updates apache config, wsgi script and restarts apache. """
     apache_make_config()
     apache_make_wsgi()
     apache_restart()
 
 @run_as('root')
 def apache_setup_locale():
-    append('/etc/apache2/envvars', ['export LANG="en_US.UTF-8"', 'export LC_ALL="en_US.UTF-8"'])
+    """ Setups apache locale. Apache is unable to handle file uploads with
+    unicode file names without this. """
+    append('/etc/apache2/envvars', [
+            'export LANG="en_US.UTF-8"', 'export LC_ALL="en_US.UTF-8"'])
 

fab_deploy/django_commands.py

 
 @inside_project
 def manage(command):
+    """ Runs django management command. """
     run('python ./manage.py '+ command)
 
 def migrate(params='', do_backup=True):
+    """ Runs migrate management command. Database backup is performed
+    before migrations if ``do_backup=False`` is not passed. """
     if do_backup:
         backup_dir = env.conf['ENV_DIR']+'/var/backups/before-migrate'
         run('mkdir -p '+ backup_dir)
     manage('migrate --noinput %s' % params)
 
 def syncdb(params=''):
+    """ Runs syncdb management command. """
     manage('syncdb --noinput %s' % params)
 
 def compress(params=''):
 
 @inside_project
 def test(what=''):
+    """ Runs 'runtests.sh' script from project root. """
     with settings(warn_only=True):
         run('./runtests.sh ' + what)
 

fab_deploy/mysql.py

 
 @run_as('root')
 def mysql_install():
+    """ Installs mysql. """
     if _mysql_is_installed():
         puts('Mysql is already installed.')
         return
 
 @inside_project
 def mysqldump(dir=None):
+    """ Runs mysqldump. Result is stored at <env>/var/backups/ """
     if dir is None:
         dir = env.conf['ENV_DIR'] + '/var/backups'
         run('mkdir -p ' + dir)
     run('mysqldump -uroot -p%s %s > %s/%s%s.sql' % (password, db, dir, db, now))
 
 def mysql_execute(sql, user=None, password=None):
+    """ Executes passed sql command using mysql shell. """
     user = user or env.conf['DB_USER']
     password = env.conf['DB_PASSWORD'] if password is None else password
     run ("echo '%s' | mysql -u%s -p%s" % (sql, user , password))
 
 def mysql_create_db():
+    """ Creates an empty mysql database. """
     db_name = env.conf['DB_NAME']
     if env.conf['DB_USER'] != 'root':
         password = prompt('Please enter mysql root password:')

fab_deploy/nginx.py

 
 @run_as('root')
 def nginx_install():
+    """ Installs nginx. """
     aptitude_install('nginx', 'lenny-backports')
     run('rm -f /etc/nginx/sites-enabled/default')
 
 @run_as('root')
 def nginx_setup():
+    """ Updates nginx config and restarts nginx. """
     name = env.conf['INSTANCE_NAME']
     upload_config_template('nginx.config', '/etc/nginx/sites-available/%s' % name)
     with settings(warn_only=True):

fab_deploy/virtualenv.py

 
 @inside_project
 def pip(commands=''):
+    """ Runs pip command """
     run('pip '+ commands)
 
 @inside_project
 def pip_install(what='active', options='', restart=True):
-    """ Installs pip requirements listed in reqs/<file>.txt file. """
+    """ Installs pip requirements listed in ``reqs/<file>.txt`` file. """
     run('pip install %s -r reqs/%s.txt' % (options, what))
     if restart:
         touch()
 
 @inside_project
 def pip_update(what='active', options='', restart=True):
-    """ Updates pip requirements listed in reqs/<file>.txt file. """
+    """ Updates pip requirements listed in ``reqs/<file>.txt`` file. """
     run('pip install %s -U -r reqs/%s.txt' % (options, what))
     if restart:
         touch()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.