Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CGI-Node run on shared hosting sites running Apache. It can run along side PHP.
Action cgi-node /cgi-bin/cgi-node.js
AddHandler cgi-node .jss</pre>
</li>
<li>Ensure you set the CGI_NODE_SESSIONDIR environment variable on your Apache instance</li>
</ul>

That's it!
2 changes: 1 addition & 1 deletion src/CgiNodeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ var CgiNodeConfig =

SessionCookie: 'CGI-NODE-SESSIONID',
SessionTimeOut: 15*60, // 15 minutes
SessionPath: 'D:/Programs/nodejs/sessions/'
SessionPath: process.env.CGI_NODE_SESSIONDIR || 'D:/Programs/nodejs/sessions/'
};
5 changes: 5 additions & 0 deletions src/CgiNodeSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function CgiHttpSession(request, response)
this.id = (request.cookies.hasOwnProperty(CgiNodeConfig.SessionCookie) ? request.cookies[CgiNodeConfig.SessionCookie] : this.create());
var path = Path.join(CgiNodeConfig.SessionPath, this.id);

// If the path doesn't exist, then create it.
if (! FS.existsSync(CgiNodeConfig.SessionPath)) {
FS.mkdirSync(CgiNodeConfig.SessionPath, 0700);
}

// If the file does not exist then create another ID.
if (!FS.existsSync(path)) this.id = this.create();

Expand Down
21 changes: 18 additions & 3 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,30 @@ var HTTP = require('http');
var QueryString = require('querystring');

// Specifies the path to where node executable exists. NOTE: windows machines require the double quotes.
var nodeExecPathLinux = '/usr/bin/nodejs'
var nodeExecPathLinux = '/usr/bin/env node';
var nodeExecPathWindows = '"D:/Programs/nodejs/node.exe"';
var nodeExecPath;

// The list of files to build in the correct order.
var files = ['CgiNodeConfig.js', 'CgiNodeContext.js', 'CgiNodeSession.js', 'CgiNodeResponse.js', 'CgiNodeRequest.js', 'CgiNodeParser.js', 'CgiNode.js'];
var files = [
'CgiNodeConfig.js',
'CgiNodeContext.js',
'CgiNodeSession.js',
'CgiNodeResponse.js',
'CgiNodeRequest.js',
'CgiNodeParser.js',
'CgiNode.js'
];

if (FS.existsSync(nodeExecPathLinux)) {
nodeExecPath = nodeExecPathLinux;
} else {
nodeExecPath = nodeExecPathWindows;
}

// The output path and file name.
var output = '../cgi-bin/cgi-node';

// Create the build class and run it.
var build = new CgiNodeBuilder();
build.run(files, output, nodeExecPathWindows);
build.run(files, output, nodeExecPath);