Skip to content

HTTPS clone URL

Subversion checkout URL

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