Example #1
0
   @author: Juliano Martinez
*/

package main

import (
	"fmt"
	docopt "github.com/docopt/docopt.go"
	"github.com/fiorix/go-redis/redis"
	hpr_utils "github.com/ncode/hot-potato-router/utils"
	"strconv"
	"strings"
)

var (
	cfg = hpr_utils.NewConfig()
	rc  = redis.New(cfg.Options["redis"]["server_list"])
)

func main() {
	usage := `Hot Potato Router Control

Usage:
  hprctl add <vhost> <backend_ip:port> [--weight=<n>]
  hprctl del <vhost> <backend_ip:port> [--weight=<n>]
  hprctl show <vhost>
  hprctl list

Args:
  add           add a new vhost and backend
  dell          del a vhost and a backend
Example #2
0
   @author: Juliano Martinez
*/

package main

import (
	"crypto/tls"
	"github.com/ncode/hot-potato-router/http_server"
	"github.com/ncode/hot-potato-router/utils"
	"net/http"
	"strconv"
	"time"
)

var (
	cfg = utils.NewConfig()
)

func main() {
	utils.Log("Starting Hot Potato Router...")
	probe_interval, _ := strconv.Atoi(cfg.Options["hpr"]["probe_interval"])
	if probe_interval == 0 {
		probe_interval = 10
	}
	s, err := http_server.NewServer(time.Duration(probe_interval) * time.Second)
	utils.CheckPanic(err, "Unable to spawn")

	if cfg.Options["hpr"]["https_addr"] != "" {
		cert, err := tls.LoadX509KeyPair(cfg.Options["hpr"]["cert_file"], cfg.Options["hpr"]["key_file"])
		utils.CheckPanic(err, "Unable to load certificate")