mirror of
https://github.com/Lissy93/dashy.git
synced 2024-09-11 14:17:02 +03:00
Add HOST environment
This is necessary in order to override which IP the Dashy process will bind to.
This commit is contained in:
parent
78bed0fb92
commit
f700f31904
@ -38,6 +38,9 @@ const isDocker = !!process.env.IS_DOCKER;
|
||||
/* Checks env var for port. If undefined, will use Port 80 for Docker, or 4000 for metal */
|
||||
const port = process.env.PORT || (isDocker ? 80 : 4000);
|
||||
|
||||
/* Checks env var for host. If undefined, will use 0.0.0.0 */
|
||||
const host = process.env.HOST || '0.0.0.0';
|
||||
|
||||
/* Attempts to get the users local IP, used as part of welcome message */
|
||||
const getLocalIp = () => {
|
||||
const dnsLookup = util.promisify(dns.lookup);
|
||||
@ -48,7 +51,7 @@ const getLocalIp = () => {
|
||||
const printWelcomeMessage = () => {
|
||||
try {
|
||||
getLocalIp().then(({ address }) => {
|
||||
const ip = address || 'localhost';
|
||||
const ip = process.env.HOST || address || 'localhost';
|
||||
console.log(printMessage(ip, port, isDocker)); // eslint-disable-line no-console
|
||||
});
|
||||
} catch (e) {
|
||||
@ -122,7 +125,7 @@ const app = express()
|
||||
|
||||
/* Create HTTP server from app on port, and print welcome message */
|
||||
http.createServer(app)
|
||||
.listen(port, () => {
|
||||
.listen(port, host, () => {
|
||||
printWelcomeMessage();
|
||||
})
|
||||
.on('error', (err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user