DEPRECATED
Go to file
Gavin M. Roy 1f506d00d6 Update the pypi password 2015-06-12 16:43:24 -04:00
sprockets Add package importing, examples to README 2015-06-12 16:35:01 -04:00
sstubs Work in progress update 2014-10-15 18:38:20 -04:00
.gitignore Initial commit 2014-10-14 16:14:46 -04:00
.travis.yml Update the pypi password 2015-06-12 16:43:24 -04:00
LICENSE Work in progress on initial commit 2014-10-14 16:32:37 -04:00
MANIFEST.in Work in progress on initial commit 2014-10-14 16:32:37 -04:00
README.rst More README clarification 2015-06-12 16:36:32 -04:00
nose.cfg Work in progress on initial commit 2014-10-14 16:32:37 -04:00
requirements-2.6.txt Work in progress on initial commit 2014-10-14 16:32:37 -04:00
requirements.txt Work in progress on initial commit 2014-10-14 16:32:37 -04:00
setup.cfg Work in progress on initial commit 2014-10-14 16:32:37 -04:00
setup.py More README and setup.py updates 2014-10-14 16:43:01 -04:00
tests.py Work in progress update 2014-10-15 18:38:20 -04:00

README.rst

sprockets.cli
=============
The sprockets CLI interface for running applications. Applications are meant
to be run by a controller that is managed by the sprockets CLI interface.

The sprockets CLI interface loads controller applications that are registered
using setuptools entry points.

|Version| |Downloads| |Status| |Coverage| |License|

Example CLI Usage
-----------------

Help:

.. code::

    # sprockets --help

    usage: sprockets [-h] [--apps] [--plugins] [-e [PLUGIN]] [-s] [-v] [--version]
                     CONTROLLER ... [APP]

    Command line tool for starting a Sprockets application

    positional arguments:
      CONTROLLER            Available sprockets application controllers
        http                HTTP Application Controller
        amqp                RabbitMQ Worker Controller
      APP                   Application to run

    optional arguments:
      -h, --help            show this help message and exit
      --apps                List installed applications
      --plugins             List installed plugins
      -e [PLUGIN], --enable [PLUGIN]
                            Enable a plugin
      -s, --syslog          Log to syslog
      -v, --verbose         Verbose logging output, use -vv for DEBUG level
                            logging
      --version             show program's version number and exit

    Find more Sprockets controllers and plugins at
    https://sprockets.readthedocs.org

Starting a Web App with the NewRelic plugin:

.. code::

    # sprockets -e newrelic http my_web_app

Controllers
-----------

Each controller is expected to expose at least a ``main(application, args)``
method that would be invoked when starting the application. Additional, a
controller can implement a ``add_cli_arguments(parser)`` method that will be
invoked when setting up the command line parameters. This allows controllers
to inject configuration directives into the cli.

Controller API Summary:

.. code:: python

    module.add_cli_arguments(ArgumentParser)     # optional
    module.main(app_module, argparse.Namespace)

Plugins
-------

Plugins are able to inject themselves at multiple points in the application
lifecycle. Plugins that implement a ``initialization(controller)`` method will
see that method invoked before a controller is started.  In addition, if a
``on_startup(controller)`` method is defined, it will be invoked after a
Controller has started a application. Finally if a ``on_shutdown(controller)``
method is defined, it will be invoked when a controller has shutdown.

Plugin API Summary:

.. code:: python

    plugin.initialize(controller_module)   # optional
    plugin.on_start(controller_module)     # optional
    plugin.on_shutdown(controller_module)  # optional

Example Entrypoints
-------------------

Controller:

.. code:: python

    {'sprockets.controller': ['http=sprockets.controllers.http:None']},

Application:

.. code:: python

    {'sprockets.http.app': ['app-name=package.or.module:None']}

(Replace ``app-name`` with the name of your application)

Applications
------------

Applications can be a python package or module and if they are registered
to a specific controller, can be referenced by an alias. Application contracts
vary by controller.

.. |Version| image:: https://badge.fury.io/py/sprockets.cli.svg?
   :target: http://badge.fury.io/py/sprockets.cli

.. |Status| image:: https://travis-ci.org/sprockets/sprockets.cli.svg?branch=master
   :target: https://travis-ci.org/sprockets/sprockets.cli

.. |Coverage| image:: https://coveralls.io/repos/sprockets/sprockets.cli/badge.png
   :target: https://coveralls.io/r/sprockets/sprockets.cli
  
.. |Downloads| image:: https://pypip.in/d/sprockets.cli/badge.svg?
   :target: https://pypi.python.org/pypi/sprockets.cli
   
.. |License| image:: https://pypip.in/license/sprockets.cli/badge.svg?
   :target: https://sprockets.readthedocs.org