Permalink
Browse files

improved samples

  • Loading branch information...
1 parent 2d0eb3a commit fd84860221ee863bc63b5b30edcb8079125bd6ad @tjanczuk tjanczuk committed Aug 30, 2011
@@ -213,23 +213,37 @@ echo $(Configuration) > $(SolutionDir)\..\..\build\$(Configuration)\$(Platfor
<ItemGroup>
<None Include="..\config\iisnode_schema.xml" />
<None Include="..\samples\configuration\hello.js" />
- <None Include="..\samples\configuration\readme.txt" />
+ <None Include="..\samples\configuration\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\configuration\web.config" />
<None Include="..\samples\defaultdocument\index.js" />
- <None Include="..\samples\defaultdocument\readme.txt" />
+ <None Include="..\samples\defaultdocument\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\defaultdocument\web.config" />
<None Include="..\samples\express\hello.js" />
+ <None Include="..\samples\express\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\express\web.config" />
<None Include="..\samples\helloworld\hello.js" />
- <None Include="..\samples\helloworld\readme.txt" />
+ <None Include="..\samples\helloworld\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\helloworld\web.config" />
<None Include="..\samples\index.htm">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="..\samples\logging\hello.js" />
- <None Include="..\samples\logging\readme.txt" />
+ <None Include="..\samples\logging\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\logging\web.config" />
<None Include="..\samples\urlrewrite\hello.js" />
+ <None Include="..\samples\urlrewrite\readme.htm">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\samples\urlrewrite\web.config" />
<None Include="..\scripts\addiisnodesectiongroup.js" />
<None Include="..\scripts\install.bat" />
@@ -160,27 +160,15 @@
<None Include="..\samples\defaultdocument\web.config">
<Filter>Samples\defaultdocument</Filter>
</None>
- <None Include="..\samples\helloworld\readme.txt">
- <Filter>Samples\helloworld</Filter>
- </None>
- <None Include="..\samples\defaultdocument\readme.txt">
- <Filter>Samples\defaultdocument</Filter>
- </None>
<None Include="..\samples\logging\hello.js">
<Filter>Samples\logging</Filter>
</None>
- <None Include="..\samples\logging\readme.txt">
- <Filter>Samples\logging</Filter>
- </None>
<None Include="..\samples\logging\web.config">
<Filter>Samples\logging</Filter>
</None>
<None Include="..\samples\configuration\hello.js">
<Filter>Samples\configuration</Filter>
</None>
- <None Include="..\samples\configuration\readme.txt">
- <Filter>Samples\configuration</Filter>
- </None>
<None Include="..\samples\index.htm">
<Filter>Samples</Filter>
</None>
@@ -205,5 +193,23 @@
<None Include="..\samples\urlrewrite\web.config">
<Filter>Samples\urlrewrite</Filter>
</None>
+ <None Include="..\samples\urlrewrite\readme.htm">
+ <Filter>Samples\urlrewrite</Filter>
+ </None>
+ <None Include="..\samples\helloworld\readme.htm">
+ <Filter>Samples\helloworld</Filter>
+ </None>
+ <None Include="..\samples\configuration\readme.htm">
+ <Filter>Samples\configuration</Filter>
+ </None>
+ <None Include="..\samples\defaultdocument\readme.htm">
+ <Filter>Samples\defaultdocument</Filter>
+ </None>
+ <None Include="..\samples\logging\readme.htm">
+ <Filter>Samples\logging</Filter>
+ </None>
+ <None Include="..\samples\express\readme.htm">
+ <Filter>Samples\express</Filter>
+ </None>
</ItemGroup>
</Project>
@@ -0,0 +1,120 @@
+<html>
+<head>
+ <title>configuration sample</title>
+ <style>
+ pre
+ {
+ background-color: eeeeee;
+ }
+ </style>
+</head>
+<body>
+ <h2>
+ configuration</h2>
+ <p>
+ There are several configuration options that can be controlled from the system.webServer/iisnode
+ section of the configurtion file. Review web.config below for detailed description
+ of them.</p>
+ visit the node.js endpoint at <a href="hello.js">hello.js</a><br />
+ visit the logs at <a href="hello.js.logs/0.txt">logs</a> (only available after you
+ first visit the endpoint)<br />
+ <p>
+ <b>code</b></p>
+ <pre>var http = require('http');
+
+http.createServer(function (req, res) {
+ console.log('A new request arrived with HTTP headers: ' + JSON.stringify(req.headers));
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
+ res.end('Hello, world! [configuration sample]');
+}).listen(process.env.PORT);
+
+console.log('Application started at location ' + process.env.PORT);</pre>
+ <p>
+ <b>web.config</b></p>
+ <pre>&lt;configuration&gt;
+ &lt;system.webServer&gt;
+
+ &lt;!-- indicates that the hello.js file is a node.js application
+ to be handled by the iisnode module --&gt;
+
+ &lt;handlers&gt;
+ &lt;add name="iisnode" path="hello.js" verb="*" modules="iisnode" /&gt;
+ &lt;/handlers&gt;
+
+ &lt;!--
+ the iisnode section configures the behavior of the node.js IIS module
+ setting values below are defaults
+
+ * nodeProcessCommandLine - command line starting the node executable; in shared
+ hosting environments this setting would typically be locked at the machine scope.
+
+ * maxProcessCountPerApplication - maximum number of node processes that IIS will start
+ per application to accomodate incresing request load
+
+ * maxConcurrentRequestsPerProcess - maximum number of reqeusts one node process can
+ handle at a time; if a request arrives while all existing node processes have reached their
+ limit, a new node process is created to handle it (up to the limit of maxProcessCountPerApplication)
+
+ * maxPendingRequestsPerApplication - maximum number of requests per application queued up to be dispatched
+ for processing by a specific node process; this is meant to accomodate temporary spikes in traffic
+ without rejecting the requests
+
+ * maxNamedPipeConnectionRetry - number of times IIS will retry to establish a named pipe connection with a
+ node process in order to send a new HTTP request
+
+ * namedPipeConnectionRetryDelay - delay in milliseconds between connection retries
+
+ * asyncCompletionThreadCount - size of the IO thread pool maintained by the IIS module to process asynchronous IO
+
+ * initialRequestBufferSize - initial size in bytes of a memory buffer allocated for a new HTTP request
+
+ * maxRequestBufferSize - maximum size in bytes of a memory buffer allocated per request; this is a hard limit of
+ the serialized form of HTTP request or response headers block
+
+ * uncFileChangesPollingInterval - applications are recycled when the underlying *.js file is modified; if the file resides
+ on a UNC share, the only reliable way to detect such modifications is to periodically poll for them; this setting
+ controls the polling interval
+
+ * gracefulShutdownTimeout - when a node.js file is modified, all node processes handling running this application are recycled;
+ this setting controls the time (in milliseconds) given for currently active requests to gracefully finish before the
+ process is terminated; during this time, all new requests are already dispatched to a new node process based on the fresh version
+ of the application
+
+ * loggingEnabled - controls whether stdout and stderr streams from node processes are captured and made available over HTTP
+
+ * logDirectoryNameSuffix - suffix of the directory name that will store files with stdout and stderr captures; directly name is created
+ by appending this suffix to the file name of the node.js application; individual log files are stored in that directory, one per node
+ process (in files of the form x.txt, where x is between 0 and maxProcessCountPerApplication - 1); given a node.js application at
+ http://localhost/node/hello.js, log files would by default be stored at http://localhost/node/hello.js.logs/0.txt (thrugh 3.txt);
+ SECURITY NOTE: if log files contain sensitive information, this setting should be modified to contain enough entropy to be considered
+ cryptographically secure; in most situations, a GUID is sufficient
+
+ * maxLogFileSizeInKB - maximum size of a log file in KB; once a log file exceeds this limit it is truncated back to empty
+
+ * appendToExistingLog - determines whether pre-existing log files are appended to or created fresh when a node process with a given ordinal
+ number starts; appending may be useful to diagnose unorderly node process terminations or recycling
+
+ --&gt;
+
+ &lt;iisnode
+ nodeProcessCommandLine="%systemdrive%\node\node.exe"
+ maxProcessCountPerApplication="4"
+ maxConcurrentRequestsPerProcess="1024"
+ maxPendingRequestsPerApplication="1024"
+ maxNamedPipeConnectionRetry="3"
+ namedPipeConnectionRetryDelay="2000"
+ asyncCompletionThreadCount="4"
+ initialRequestBufferSize="4096"
+ maxRequestBufferSize="65536"
+ uncFileChangesPollingInterval="5000"
+ gracefulShutdownTimeout="60000"
+ loggingEnabled="true"
+ logDirectoryNameSuffix="logs"
+ maxLogFileSizeInKB="128"
+ appendToExistingLog="false"
+ /&gt;
+
+ &lt;/system.webServer&gt;
+&lt;/configuration&gt;</pre>
+</body>
+</html>
@@ -1,6 +0,0 @@
-This is the configuration sample showing all configuration options related to hosting node.js applications in IIS.
-
-Key points:
-
-1. There are several configuration options that can be controlled from the system.webServer/iisnode section of
- the configurtion file. Review web.config for detailed description of them.
@@ -0,0 +1,52 @@
+<html>
+<head>
+ <title>defaultdocument sample</title>
+ <style>
+ pre
+ {
+ background-color: eeeeee;
+ }
+ </style>
+</head>
+<body>
+ <h2>
+ defaultdocument</h2>
+ <p>
+ The &lt;defaultDocument&gt; element in web.config may specify a default node.js application file
+ that IIS will serve when the request URL does not specify any file name, e.g.
+ http://localhost/node/defaultdocument/.</p>
+ visit the <a href="./">default node.js endpoint</a><br />
+ <p>
+ <b>code [index.js]</b></p>
+ <pre>var http = require('http');
+
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end('You have reached the default node.js application at index.js! [defaultdocument sample]');
+}).listen(process.env.PORT); </pre>
+ <p>
+ <b>web.config</b></p>
+ <pre>&lt;configuration&gt;
+ &lt;system.webServer&gt;
+
+ &lt;!-- indicates that the index.js file is a node.js application
+ to be handled by the iisnode module --&gt;
+
+ &lt;handlers&gt;
+ &lt;add name="iisnode" path="index.js" verb="*" modules="iisnode" /&gt;
+ &lt;/handlers&gt;
+
+ &lt;!-- adds index.js to the default document list to allow
+ URLs that only specify the application root location,
+ e.g. http://mysite.antarescloud.com/ --&gt;
+
+ &lt;defaultDocument enabled="true"&gt;
+ &lt;files&gt;
+ &lt;add value="index.js" /&gt;
+ &lt;/files&gt;
+ &lt;/defaultDocument&gt;
+
+ &lt;/system.webServer&gt;
+&lt;/configuration&gt;</pre>
+</body>
+</html>
@@ -1,7 +0,0 @@
-This is the defaultdocument sample showing how to configure a default node.js application in IIS
-
-Key points:
-
-1. The <defaultDocument> element in web.config may specify a default node.js application file
- that IIS will serve when the request URL does not specify any file name, e.g.
- http://localhost/node/defaultdocument/.
@@ -0,0 +1,90 @@
+<html>
+<head>
+ <title>express sample</title>
+ <style>
+ pre
+ {
+ background-color: eeeeee;
+ }
+ </style>
+</head>
+<body>
+ <h2>
+ express</h2>
+ <p>
+ node.js apps that use the popular <a href="http://expressjs.com/">express</a> framework
+ can be hosted in IIS.</p>
+ <ul>
+ <li>Express framework can be installed on Windows using <a href="https://github.com/japj/ryppi">
+ ryppi.py</a> while we wait for NPM support.</li>
+ <li>Remember that you may or may not own the entire URL space within an express application
+ when designing your URL structure - see code below.</li>
+ <li>The URL rewrite module is recommended for all but the most simple express applications
+ hosted in IIS. The sample below shows how to use it, but also check out the <a href="../urlrewrite/readme.htm">
+ urlrewrite sample</a>.</li>
+ <li>Remember to exclude the node_modules directory from serving from IIS - see web.config
+ below.</li>
+ </ul>
+ visit the foo endpoint at <a href="hello/foo">hello/foo</a><br />
+ visit the bar endpoint at <a href="hello/bar">hello/bar</a><br />
+ visit the nonexistent endpoint at <a href="hello/idontexist">hello/idontexist</a><br />
+ <p>
+ <b>code</b></p>
+ <pre>var express = require('express');
+
+var app = express.createServer();
+
+app.get('/node/express/hello/foo', function (req, res) {
+ res.send('Hello from foo! [express sample]');
+});
+
+app.get('/node/express/hello/bar', function (req, res) {
+ res.send('Hello from bar! [express sample]');
+});
+
+app.listen(process.env.PORT);</pre>
+ <p>
+ <b>web.config</b></p>
+ <pre>&lt;configuration&gt;
+ &lt;system.webServer&gt;
+
+ &lt;!-- indicates that the hello.js file is a node.js application
+ to be handled by the iisnode module --&gt;
+
+ &lt;handlers&gt;
+ &lt;add name="iisnode" path="hello.js" verb="*" modules="iisnode" /&gt;
+ &lt;/handlers&gt;
+
+ &lt;!-- use URL rewriting to redirect the entire branch of the URL namespace
+ to hello.js node.js application; for example, the following URLs will
+ all be handled by hello.js:
+
+ http://localhost/node/express/hello/foo
+ http://localhost/node/express/hello/bar
+
+ --&gt;
+
+ &lt;rewrite&gt;
+ &lt;rules&gt;
+ &lt;rule name="hello"&gt;
+ &lt;match url="hello/*" /&gt;
+ &lt;action type="Rewrite" url="hello.js" /&gt;
+ &lt;/rule&gt;
+ &lt;/rules&gt;
+ &lt;/rewrite&gt;
+
+ &lt;!-- exclude node_modules directory and subdirectories from serving
+ by IIS since these are implementation details of node.js applications --&gt;
+
+ &lt;security&gt;
+ &lt;requestFiltering&gt;
+ &lt;hiddenSegments&gt;
+ &lt;add segment="node_modules" /&gt;
+ &lt;/hiddenSegments&gt;
+ &lt;/requestFiltering&gt;
+ &lt;/security&gt;
+
+ &lt;/system.webServer&gt;
+&lt;/configuration&gt;</pre>
+</body>
+</html>
@@ -0,0 +1 @@
+var hello = "This is a client side JavaScript file served statically";
Oops, something went wrong.

0 comments on commit fd84860

Please sign in to comment.