-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
98 lines (73 loc) · 1.91 KB
/
server.js
File metadata and controls
98 lines (73 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
'use strict';
//
// Require some modules
//
var fs = require('fs');
var connect = require('connect');
//var hamlc = require('haml-coffee');
var Mincer = require('mincer');
var spawn = require("child_process").spawn;
var railo = spawn('railo_init');
railo.stdout.on('data', function (data) {
console.log('railo: ' + data);
});
railo.stderr.on('data', function (data) {
console.log('railo: ' + data);
});
railo.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
//
// Get Mincer environment
//
var environment = require('./environment');
//console.log(environment);
//
// Create connect application
//
var app = connect();
//
// Fix NODE_ENV environment variable
//
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
//console.log(process.env.NODE_ENV);
//
// Attach assets server
//
app.use('/assets/', Mincer.createServer(environment));
//
// Prepare HTML layout for our dummy application
// See `views/layout.jade` for example of `javascript` and `stylesheet` usage.
//
//
// Define some view helpers
//
//
// Attach some dummy handler, that simply renders layout
//
app.use(function (req, res, next) {
// make sure our assets were compiled, so their `digestPath`
// will be 100% correct, otherwise first request will produce
// wrong digestPath. That's not a big deal, as assets will be
// served anyway, but to keep everything correct, we use this
// precompilation, which is similar to using manifest, but
// without writing files on disk.
//
// See [[Base#precompile]] for details,
environment.precompile(['application.js', 'application.css'], function (err) {
if (err) {
next(err);
return;
}
});
});
//
// Start listening
//
app.listen(3000, function (err) {
if (err) {
console.error("Failed start server: " + (err.message || err.toString()));
process.exit(128);
}
console.info('Listening on localhost:3000');
});