Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (50 sloc) 3.218 kB
78493bc @creationix Start the readme.
creationix authored
1 # Spark
2
0fb0dfe @tj Doc typo
tj authored
3 Spark is a command-line tool used to start up node server instances written by [Tj Holowaychuk](http://github.com/visionmedia) and [Tim Caswell](http://github.com/creationix). It's part of the [Connect](http://github.com/senchalabs/connect) framework, however can be used standalone with _any_ node server.
78493bc @creationix Start the readme.
creationix authored
4
c811f2f @tj use cluster instead
tj authored
5 __NOTE__: spark is no longer maintained, for an extensible, and more robust solution check out [Cluster](http://learnboost.github.com/cluster).
6
78493bc @creationix Start the readme.
creationix authored
7 ## Features
8
9 Spark provides the following options when starting a server.
10
11 - Port/Host to listen on
12 - SSL hosting with specified key/certificate
13 - Automatic child process spawning for multi-process node servers that share a common port.
14 - User/Group to drop to after binding (if run as root)
15 - Environment modes (development/testing/production)
16 - Modify the node require paths
17 - Can load any of these configs from from a file (optionally grouped by env)
18 - Can change the working directory before running the app
19 - `--comment` option to label processes in system tools like `ps` or `htop`
20 - Pass arbitrary code or environment variables to the app
21
22 ## Making an app spark compatible
23
24 Any node server can be used with spark. All you need to do it create a file called `app.js` that exports the instance of `http.Server` or `net.Server`.
25
26 A hello-world example would look like this:
27
28 module.exports = require('http').createServer(function (req, res) {
49be2a4 @tj Readme fixes
tj authored
29 res.writeHead(200, {"Content-Type":"text-plain"});
30 res.end("Hello World");
78493bc @creationix Start the readme.
creationix authored
31 });
32
33 And then to run it you simply go to the folder containing the `app.js` and type:
34
e3e0a0b @tj Small doc fixes
tj authored
35 $ spark
78493bc @creationix Start the readme.
creationix authored
36
37 The output you'll see will be:
38
39 Spark server(34037) listening on http://*:3000 in development mode
40
49be2a4 @tj Readme fixes
tj authored
41 Where `34037` is the process id. If you want 4 processes to balance the requests across, no problem.
78493bc @creationix Start the readme.
creationix authored
42
e3e0a0b @tj Small doc fixes
tj authored
43 $ spark -n 4
78493bc @creationix Start the readme.
creationix authored
44
45 And you'll see:
46
47 Spark server(34049) listening on http://*:3000 in development mode
48 Spark server(34050) listening on http://*:3000 in development mode
49 Spark server(34052) listening on http://*:3000 in development mode
50 Spark server(34051) listening on http://*:3000 in development mode
51
5fe8c2a @creationix Add explicit MIT license to the README.
creationix authored
52 ## MIT License
53
54 Copyright (c) 2010 Sencha Inc.
55
56 Permission is hereby granted, free of charge, to any person obtaining a copy
57 of this software and associated documentation files (the "Software"), to deal
58 in the Software without restriction, including without limitation the rights
59 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
60 copies of the Software, and to permit persons to whom the Software is
61 furnished to do so, subject to the following conditions:
62
63 The above copyright notice and this permission notice shall be included in
64 all copies or substantial portions of the Software.
65
66 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
67 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
68 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
69 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
70 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
71 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
72 THE SOFTWARE.
Something went wrong with that request. Please try again.