Eric Larson avatar Eric Larson committed 6fa8783 Draft

Updated the README for the ServiceStarter plugin

Comments (0)

Files changed (1)

 the Autoreloader plugin with the primary difference that it does not
 restart the engine and instead calls a function.
 
+AutoRebuild also provides a ServiceStarter plugin that will start a
+service for you. As this tool was originally written to support things
+like sass and less where you want CSS changes to be reflected
+immediately and automatically, the ServiceStarter will let you start
+up something like "sass --watch". 
 
-Usage
-=====
+More generally though, the ServiceStarter plugin can help you
+configure extra services you might need running in development or in
+testing. This avoids the necessity to use something like Foreman for
+service coordination in development.
 
-Here is a simple example provided in the code: ::
+
+AutoRebuild Usage
+=================
+
+Here is a simple example: ::
 
   import cherrypy
   from autorebuild import AutoRebuild
 Pretty simple.
 
 
+ServiceStarter Example
+======================
+
+Here is a simple example: ::
+
+    import cherrypy
+
+    class Root(object):
+        def index(self):
+            return 'Hello World!'
+        index.exposed = True
+
+    # Adding a service starter instance
+    cherrypy.engine.projserver = ServiceStarter(cherrypy.engine)
+    cherrypy.engine.projserver.subscribe()
+
+    # Configure the stdlib simple server to run on port 9000 in the
+    # current directory
+    cherrypy.config.update({
+            'engine.projserver.cmd': 'python -m SimpleHTTPServer 9000'
+    })
+
+    cherrypy.tree.mount(Root(), '/')
+    cherrypy.engine.start()
+    cherrypy.engine.block()
+
+Assuming you run this in the root of your source, you can now visit
+http://localhost:9000 to see the actual Python files.
+
+
 History
 =======
 
 A developer asked me if there was a good way to force CherryPy to
 restart and rebuild some sass_ files when the files changed. Knowing
 that the Autoreloader plugin already existed it seemed trivial to
-implement. The immediate solution was to simply use the sass command
-line watcher script in a foreman procfile, but thinking about it, it
-seemed pretty silly when you could do it in CherryPy relatively easily
-and avoid having to depend on something like foreman all together.
+implement. The immediate solution was to simply use the 'sass --watch'
+command in a foreman procfile, but thinking about it, it seemed pretty
+silly when you could do it in CherryPy relatively easily and avoid
+having to depend on something like foreman all together.
 
 I then realized there were tools like CodeKit_ people were actually
-selling to do this for you and it seemed ridiculous that this isn't
-built in.
+selling to do this for you and it seemed ridiculous that there wasn't
+an easy way to do this in CherryPy. Fortunately, thanks to the WSPBus_
+in CherryPy, it was a breeze.
 
 
 .. _sass: http://sass-lang.com
 .. _CodeKit: http://incident57.com/codekit/
+.. _WSPBus: http://docs.cherrypy.org/stable/refman/process/wspbus.html
 
-
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.