Standalone » History » Version 1
Jan Klopper, 2012-03-13 15:13
| 1 | 1 | Jan Klopper | h1. Standalone |
|---|---|---|---|
| 2 | 1 | Jan Klopper | |
| 3 | 1 | Jan Klopper | µWeb's standalone mode allows you to develop an application or website without installing / configuring a full-fledged webserver like apache. By keeping all of the environment the same as it would be inside a normal webserver it allows you to code once, and run on both types of install. |
| 4 | 1 | Jan Klopper | |
| 5 | 1 | Jan Klopper | A default standalone server can be started by issuing a 'start' command on the router. Obviously 'stop' and 'restart' are also supported. |
| 6 | 1 | Jan Klopper | |
| 7 | 1 | Jan Klopper | The default ip/port the standalone will bind to are: localhost:8082, which you can then use to connect to your server via a browser. |
| 8 | 1 | Jan Klopper | |
| 9 | 1 | Jan Klopper | h2. Custom ip/port |
| 10 | 1 | Jan Klopper | |
| 11 | 1 | Jan Klopper | Using a custom port and or ip can be attained by setting a config file in the router with the 'CONFIG' variable, and in that config list the following settings: |
| 12 | 1 | Jan Klopper | <pre> |
| 13 | 1 | Jan Klopper | [standalone] |
| 14 | 1 | Jan Klopper | port = 4001 |
| 15 | 1 | Jan Klopper | </pre> |
| 16 | 1 | Jan Klopper | |
| 17 | 1 | Jan Klopper | If you want to use 1 config file for multiple standalone servers, eg, you want to centralize certain settings, but have others on a server by server basis, you can issue a more specific block for each server using the package name as defined in the router using the 'PACKAGE' variable. For example, a demo router would look like this: |
| 18 | 1 | Jan Klopper | |
| 19 | 1 | Jan Klopper | |
| 20 | 1 | Jan Klopper | <pre> |
| 21 | 1 | Jan Klopper | <code class="python"> |
| 22 | 1 | Jan Klopper | import uweb |
| 23 | 1 | Jan Klopper | import pages |
| 24 | 1 | Jan Klopper | CONFIG = '../demo.conf' |
| 25 | 1 | Jan Klopper | PACKAGE = 'demo' |
| 26 | 1 | Jan Klopper | PAGE_CLASS = pages.PageMaker |
| 27 | 1 | Jan Klopper | ROUTES = ( |
| 28 | 1 | Jan Klopper | ('/', 'requestIndex'), |
| 29 | 1 | Jan Klopper | ('(/.*)', 'requestFail')) |
| 30 | 1 | Jan Klopper | |
| 31 | 1 | Jan Klopper | uweb.ServerSetup() |
| 32 | 1 | Jan Klopper | </code> |
| 33 | 1 | Jan Klopper | </pre> |
| 34 | 1 | Jan Klopper | This would read from the ../demo.conf file (relative to the location of the router) and look for both a [standalone] and a [standalone:demo] subsection |
| 35 | 1 | Jan Klopper | <pre> |
| 36 | 1 | Jan Klopper | [standalone:demo] |
| 37 | 1 | Jan Klopper | port = 8080 |
| 38 | 1 | Jan Klopper | |
| 39 | 1 | Jan Klopper | [standalone] |
| 40 | 1 | Jan Klopper | access_logging = 0 |
| 41 | 1 | Jan Klopper | error_logging = 0 |
| 42 | 1 | Jan Klopper | </pre> |
| 43 | 1 | Jan Klopper | |
| 44 | 1 | Jan Klopper | As you can see, by setting the access_logging and error_logging vars you can make sure the server doesn't log these actions and thus speeds up a bit. |