var findServer = function (hostConfig, serverName) {

  if (hostConfig === undefined) {
    console.log('===ERROR=== 获取服务器配置信息时发生错误，请检查服务器配置!!!\n')
    return ''
  }

  if (serverName === undefined) {
    console.log('===ERROR=== 函数传参错误，请检查服务器配置!!!\n')
    return ''
  }

  var targetServer = hostConfig[serverName]
  if (targetServer === undefined ) {
    console.log('===ERROR=== 服务' + serverName +'配置信息错误，请检查服务器配置!!!\n')
    return ''
  }

  var addr = ''
  if (targetServer.port === 0) {
    addr =  targetServer.addr + targetServer.path
  } else {
    addr =  targetServer.addr + ':' + targetServer.port.toString() + targetServer.path
  }
  return addr
}

module.exports = findServer