use hostname binary if we don't find an /etc/hostname

This commit is contained in:
pmaechler 2018-08-15 16:24:42 +02:00
parent 8b83cf4fed
commit f32eefe31a
1 changed files with 5 additions and 1 deletions

6
app.js
View File

@ -109,7 +109,11 @@ global.socket_clients = 0;
/**
* Server hostname
*/
global.host_name = execSync("cat /etc/hostname").toString().replace("\n", "");
try {
global.host_name = execSync("cat /etc/hostname").toString().replace("\n", "");
} catch (e) {
global.host_name = execSync("/usr/bin/env hostname -s").toString().replace("\n", "");
}
/**
* Pull in core handlers