Standalone » History » Version 2
Version 1 (Jan Klopper, 2012-03-13 15:13) → Version 2/6 (Elmer de Looff, 2012-05-07 16:44)
h1. Standalone
µWeb's standalone mode allows you to develop, run and test your website/application develop an application or website without needing installing / configuring a web server on your local machine. This enables rapid application development and when it's time to migrate over to [[Apache]], everything will work full-fledged webserver like apache. By keeping all of the environment the same way as it did would be inside a normal webserver it allows you to code once, and run on here. both types of install.
When running standalone, starting A default standalone server can be started by issuing a 'start' command on the router. Obviously 'stop' and stopping 'restart' are also supported.
The default ip/port the web standalone will bind to are: localhost:8082, which you can then use to connect to your server is done via a browser.
h2. Custom ip/port
Using a custom port and or ip can be attained by invoking setting a config file in the router:
<pre><code class="bash"> router with the 'CONFIG' variable, and in that config list the following settings:
$ python uweb_info/www/router.py
Usage: router.py start | stop | restart <pre>
</code></pre> [standalone]
port = 4001
</pre>
An argument needs If you want to be provided use 1 config file for multiple standalone servers, eg, you want to start/stop or restart centralize certain settings, but have others on a server by server basis, you can issue a more specific block for each server using the router. Providing this will initiate package name as defined in the obvious action.
h2. Expanding your configuration
The entry point for router using the standalone project is the [[request router]], with 'PACKAGE' variable. For example, a few additional global variables that can be used to configure Standalone:
<pre><code demo router would look like this:
<pre>
<code class="python">
#!/usr/bin/python
"""A uWeb demonstration project."""
# uWeb Framework
import uweb
# Project's controller
from uweb.uweb_info import pages
# uWeb standalone configuration keys
CONFIG = 'example.conf' '../demo.conf'
PACKAGE = 'uweb_info'
'demo'
PAGE_CLASS = pages.PageMaker
ROUTES = (
('/static/(.*)', 'Static'), ('/', 'requestIndex'),
('/(broken.*)', 'FourOhFour'),
('/haltandcatchfire', 'MakeFail'),
('/json', 'Json'),
('/text', 'Text'),
('/redirect/(.*)', 'Redirect'),
('/OpenIDLogin', '_OpenIdInitiate'),
('/OpenIDValidate', '_OpenIdValidate'),
('/ULF-Challenge', '_ULF_Challenge'),
('/ULF-Login', '_ULF_Verify'),
('/(.*)', 'Index')) ('(/.*)', 'requestFail'))
uweb.ServerSetup()
</code></pre>
Compared to the request router, there are two new global variables here:
# @CONFIG@ is used to indicate the path for the configuration file, if there is any. </code>
</pre>
This is a path to the configuration file (explained below), relative would read from the router path. In this router, the configuration ../demo.conf file is a file named @example.conf@ in the same directory as the router. If there is no configuration file, this variable should be omitted.
# @PACKAGE@ is used (relative to indicate the package name location of the project. The package name is used to group logfiles by. Logfiles will be automatically created router) and written to either @/var/log/underdark/$PACKAGE/@ or @~/.underdark/$PACKAGE/@, whichever is writable. If no explicit @PACKAGE@ variable is set, the name of the directory one above the router directory will be used. In the case of the example project, the router is in look for both a directory @uweb/uweb_info/www/@, meaning that the package name is *@uweb_info@*
h1. Standalone configuration
The standalone server can be configured to bind to [standalone] and a specific port, and enable/disable request logging. The following is an explicit definition of the default settings:
<pre><code class="ini"> [standalone:demo] subsection
[standalone] <pre>
[standalone:demo]
port = 8082 8080
[standalone]
access_logging = True 0
error_logging = True 0
</code></pre> </pre>
Running As you can see, by setting the standalone web access_logging and error_logging vars you can make sure the server on a different port is a matter of specifying the new port doesn't log these actions and (re)starting the process. True/Fales values can be passed along as strings, or as integers depending on your preference.
h2. Multiple routers on one config file
You can have multiple routers (in standalone mode) using thus speeds up a single configuration file. This can be beneficial if they share many other settings, but still need their own port allocations (because only one webserver can bind to a given port). Standalone settings can be specifically assigned to a single router module, thereby allowing multiple router configurations (as long as they have differing filenames).
<pre><code class="ini">
[standalone]
access_logging = True
error_logging = True
[standalone:website]
port = 8000
[standalone:admin]
port = 8001
access_logging = False
</code></pre>
This configuration block explicitly enables logging for all routers, but then disables access logging for the @admin@ router. The @website@ router will run on port 8000, but the @admin@ router will run on port 8001. bit.
µWeb's standalone mode allows you to develop, run and test your website/application develop an application or website without needing installing / configuring a web server on your local machine. This enables rapid application development and when it's time to migrate over to [[Apache]], everything will work full-fledged webserver like apache. By keeping all of the environment the same way as it did would be inside a normal webserver it allows you to code once, and run on here. both types of install.
When running standalone, starting A default standalone server can be started by issuing a 'start' command on the router. Obviously 'stop' and stopping 'restart' are also supported.
The default ip/port the web standalone will bind to are: localhost:8082, which you can then use to connect to your server is done via a browser.
h2. Custom ip/port
Using a custom port and or ip can be attained by invoking setting a config file in the router:
<pre><code class="bash"> router with the 'CONFIG' variable, and in that config list the following settings:
$ python uweb_info/www/router.py
Usage: router.py start | stop | restart <pre>
</code></pre> [standalone]
port = 4001
</pre>
An argument needs If you want to be provided use 1 config file for multiple standalone servers, eg, you want to start/stop or restart centralize certain settings, but have others on a server by server basis, you can issue a more specific block for each server using the router. Providing this will initiate package name as defined in the obvious action.
h2. Expanding your configuration
The entry point for router using the standalone project is the [[request router]], with 'PACKAGE' variable. For example, a few additional global variables that can be used to configure Standalone:
<pre><code demo router would look like this:
<pre>
<code class="python">
#!/usr/bin/python
"""A uWeb demonstration project."""
# uWeb Framework
import uweb
# Project's controller
from uweb.uweb_info import pages
# uWeb standalone configuration keys
CONFIG = 'example.conf' '../demo.conf'
PACKAGE = 'uweb_info'
'demo'
PAGE_CLASS = pages.PageMaker
ROUTES = (
('/static/(.*)', 'Static'), ('/', 'requestIndex'),
('/(broken.*)', 'FourOhFour'),
('/haltandcatchfire', 'MakeFail'),
('/json', 'Json'),
('/text', 'Text'),
('/redirect/(.*)', 'Redirect'),
('/OpenIDLogin', '_OpenIdInitiate'),
('/OpenIDValidate', '_OpenIdValidate'),
('/ULF-Challenge', '_ULF_Challenge'),
('/ULF-Login', '_ULF_Verify'),
('/(.*)', 'Index')) ('(/.*)', 'requestFail'))
uweb.ServerSetup()
</code></pre>
Compared to the request router, there are two new global variables here:
# @CONFIG@ is used to indicate the path for the configuration file, if there is any. </code>
</pre>
This is a path to the configuration file (explained below), relative would read from the router path. In this router, the configuration ../demo.conf file is a file named @example.conf@ in the same directory as the router. If there is no configuration file, this variable should be omitted.
# @PACKAGE@ is used (relative to indicate the package name location of the project. The package name is used to group logfiles by. Logfiles will be automatically created router) and written to either @/var/log/underdark/$PACKAGE/@ or @~/.underdark/$PACKAGE/@, whichever is writable. If no explicit @PACKAGE@ variable is set, the name of the directory one above the router directory will be used. In the case of the example project, the router is in look for both a directory @uweb/uweb_info/www/@, meaning that the package name is *@uweb_info@*
h1. Standalone configuration
The standalone server can be configured to bind to [standalone] and a specific port, and enable/disable request logging. The following is an explicit definition of the default settings:
<pre><code class="ini"> [standalone:demo] subsection
[standalone] <pre>
[standalone:demo]
port = 8082 8080
[standalone]
access_logging = True 0
error_logging = True 0
</code></pre> </pre>
Running As you can see, by setting the standalone web access_logging and error_logging vars you can make sure the server on a different port is a matter of specifying the new port doesn't log these actions and (re)starting the process. True/Fales values can be passed along as strings, or as integers depending on your preference.
h2. Multiple routers on one config file
You can have multiple routers (in standalone mode) using thus speeds up a single configuration file. This can be beneficial if they share many other settings, but still need their own port allocations (because only one webserver can bind to a given port). Standalone settings can be specifically assigned to a single router module, thereby allowing multiple router configurations (as long as they have differing filenames).
<pre><code class="ini">
[standalone]
access_logging = True
error_logging = True
[standalone:website]
port = 8000
[standalone:admin]
port = 8001
access_logging = False
</code></pre>
This configuration block explicitly enables logging for all routers, but then disables access logging for the @admin@ router. The @website@ router will run on port 8000, but the @admin@ router will run on port 8001. bit.