func handleOfflineWorkers(online workerChan, offline workerChan) {
	for {
		<-time.After(1 * time.Second)
		for worker := range offline {
			conn, err := rpc.DialHTTP("tcp", fmt.Sprintf("%s:%d", worker.Host, worker.Port))
			if err != nil {
				offline <- worker
			} else {
				log.Printf("Worker %s (%s:%d), CONNECTED \n", worker.Name, worker.Host, worker.Port)
				worker.Conn = conn
				online <- worker
			}
		}
	}
}
handleOfflineWorkers trying to reconnect offline workers every one second. When worker will reconnect
send him to online chanel
package goworld
import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/rpc"
	"net/url"
	"strings"
	"time"
)
var (
	pathToReques = map[string]string{
		"list":   "Worker.ListObjectsFields",
		"custom": "Worker.Custom",
	}
)
type workerChan chan *WorkerConnection
func StartServer(config *Config, mode WorkMode) {
	online, offline := initWorkersConnections(config.Workers)
	go handleOfflineWorkers(online, offline)
	startHTTPServer(config, online, offline, mode)
	defer func() {
		if err := recover(); err != nil {
			log.Panic("PANIC ", err)
		}
	}()
}
func startHTTPServer(config *Config, online workerChan, offline workerChan, mode WorkMode) {
	port := config.Server.Port
	log.Printf("HTTP server started on port: %v\n", port)
	server := &http.Server{
		Addr: portNo(port),
		Handler: &ReqHandler{Online: online,
			Offline:  offline,
			Config:   config,
			WorkMode: mode},
		ReadTimeout:    1 * time.Minute,
		WriteTimeout:   1 * time.Minute,
		MaxHeaderBytes: 1 << 20,
	}
	log.Printf("SERVWER ERROR!\n %s\n", server.ListenAndServe())
}
func initWorkersConnections(workersDef []*WorkerConf) (onlineWorkers workerChan, offlineWorkers workerChan) {
	workersNo := len(workersDef)
	onlineWorkers = make(workerChan, workersNo)
	offlineWorkers = make(workerChan, workersNo)
	for _, workerDef := range workersDef {
		conn, err := rpc.DialHTTP("tcp", fmt.Sprintf("%s:%d", workerDef.Host, workerDef.Port))
		if err != nil {
			offlineWorkers <- &WorkerConnection{Host: workerDef.Host,
				Port: workerDef.Port,
				Name: workerDef.Name}
			continue
		}
		onlineWorkers <- &WorkerConnection{Host: workerDef.Host,
			Port: workerDef.Port,
			Name: workerDef.Name,
			Conn: conn}
		log.Printf("Worker %s (%s:%d), CONNECTED \n", workerDef.Name, workerDef.Host, workerDef.Port)
	}
	return
}