Permalink
Browse files

Automatically try socket based activation

When not called by systemd, fall back to the http and https based
configuration from the config file (default: IPv4 port 80 only).
  • Loading branch information...
andreas-gruenbacher committed Apr 18, 2017
1 parent 62fbb42 commit 5a80e721cf159f69bfdec6548072438f14925dd4
Showing with 12 additions and 10 deletions.
  1. +12 −9 backend/index.js
  2. +0 −1 systemd/trialinfo.service
View
@@ -3805,17 +3805,20 @@ app.delete('/api/serie/:serie', will_write_serie, async function(req, res, next)
app.use(clientErrorHandler);
if (!config.http && !config.https)
config.http = {};
if (process.env.TRIALINFO == 'systemd') {
require('autoquit');
require('systemd');
try {
var http = require('http');
var server = http.createServer(app);
server.autoQuit({timeout: 300 });
require('systemd');
server.listen('systemd');
} else {
/* We don't get here unless started by systemd. */
require('autoquit');
server.autoQuit({timeout: 300 });
} catch (_) {
if (!config.http && !config.https)
config.http = {};
if (config.http) {
var http = require('http');
var port = config.http.port || 80;
@@ -3832,6 +3835,6 @@ if (process.env.TRIALINFO == 'systemd') {
var port = config.https.port || 443;
https.createServer(options, app).listen(port);
}
}
};
/* ex:set shiftwidth=2: */
@@ -9,4 +9,3 @@ SyslogIdentifier=trialinfo
User=trialinfo
Group=trialinfo
Environment=NODE_ENV=production
Environment=TRIALINFO=systemd

0 comments on commit 5a80e72

Please sign in to comment.