Skip to content

Commit

Permalink
Using $HOSTNAME as default app.hostname value.
Browse files Browse the repository at this point in the history
Currently, Peel uses `InetAddress.getLocalHost.getHostName` to get the
default value for `app.hostname`. This causes confusion on hosts where
the value differs from `$HOSTNAME`, as most system scripts use the latter
per default (e.g. jobtracker log name construction in Hadoop).
  • Loading branch information
aalexandrov committed Feb 8, 2016
1 parent e86ae10 commit 77d83f6
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions peel-core/src/main/scala/org/peelframework/core/cli/Peel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/
package org.peelframework.core.cli

import java.net.InetAddress
import java.nio.file.Paths

import org.peelframework.core.PeelApplicationContext
import org.peelframework.core.cli.command.Command
import net.sourceforge.argparse4j.ArgumentParsers
import net.sourceforge.argparse4j.impl.Arguments
import net.sourceforge.argparse4j.inf.ArgumentParserException
import net.sourceforge.argparse4j.internal.HelpScreenException
import org.apache.log4j.{PatternLayout, RollingFileAppender}
import org.peelframework.core.PeelApplicationContext
import org.peelframework.core.cli.command.Command
import org.peelframework.core.util.shell
import org.slf4j.{Logger, LoggerFactory}

import scala.collection.JavaConversions._
Expand Down Expand Up @@ -127,12 +127,12 @@ object Peel {
.`type`(classOf[String])
.dest("app.hostname")
.metavar("NAME")
.help("hostname for config resolution (app.hostname)")
.help(s"environment hostname (default: $hostname)")
parser.addArgument("--config")
.`type`(classOf[String])
.dest("app.path.config")
.metavar("PATH")
.help("config folder (app.path.config)")
.help("config folder (default: config)")
parser.addArgument("--experiments")
.`type`(classOf[String])
.dest("app.path.experiments")
Expand All @@ -142,7 +142,7 @@ object Peel {
.`type`(classOf[String])
.dest("app.path.log")
.metavar("PATH")
.help("log folder (app.path.log)")
.help("log folder (default: log)")

if (!basicOnly) {
parser.addSubparsers()
Expand All @@ -166,12 +166,9 @@ object Peel {
parser
}

def hostname = {
try {
InetAddress.getLocalHost.getHostName
} catch {
case _: Throwable => "localhost"
}
lazy val hostname = {
val name = shell !! "echo $HOSTNAME"
if (name.nonEmpty) name else "localhost"
}

def printHeader(logger: Logger) {
Expand Down

0 comments on commit 77d83f6

Please sign in to comment.