Files
purple-explorer/bin/instance
T
Joe Uhren 8bcb995728 Cluster + instance improvements
-Moved the database initialize call out of the instance code into the prestart script so that it is now only called once when you start the explorer even if you are running multiple cpus/threads
-The database connection function now uses the default connection string in the event a connection string is not supplied
-Removed unused reference to lib/explorer.js code from the cluster file
2023-08-20 20:41:41 -06:00

27 lines
775 B
JavaScript

#!/usr/bin/env node
var debug = require('debug')('explorer');
var settings = require('../lib/settings');
var db = require('../lib/database');
var app = require('../app');
app.set('port', process.env.PORT || settings.webserver.port);
db.connect(null, function() {
var server = app.listen(app.get('port'), '::', function() {
debug('Express server listening on port ' + server.address().port);
});
process.on('SIGINT', () => {
server.close(() => {
var mongoose = require('mongoose');
mongoose.connection.close(false).then(() => {
// close the main process now that all http and database connections have closed
process.exit(0);
}).catch((err) => {
console.log(err);
process.exit(1);
});
});
});
});