func (database *Database) HandleSigHup(){
	for {
		c := make(chan os.Signal, 1)
		signal.Notify(c, syscall.SIGHUP)
		for range c {
			ok := false
			tempConfig, ok := ReloadConfig(os.Args[1])
			if ok {
				if !reflect.DeepEqual(tempConfig, database.config) {
					if !reflect.DeepEqual(tempConfig.Cluster, database.config.Cluster) {
						database.config = tempConfig
						database.cluster = database.config.CreateCluster()
						database.config.logger("Nipo reloaded", 1)
						database.Run(1)
					} else {
						database.config = tempConfig
						database.cluster = database.config.CreateCluster()
						database.config.logger("Nipo reloaded", 1)
						database.Run(2)
					}
				} else {
					database.config.logger("Nipo NOT reloaded, config file does not changed ", 1)
				}
			}
		}
	}
}
/*
handles sighup from OS
package main
import (
	"bufio"
	"encoding/json"
	"net"
	"os"
	"os/signal"
	"syscall"
	"runtime"
	"strings"
	"reflect"
)
func CreateClient() *Client {
	return &Client{}
}
func (client *Client) Validate(token string, config *Config) bool {
	client.Authorized = false
	for _, tempuser := range config.Acl.Users {
		if token == tempuser.Token {
			client.Authorized = true
			client.User = *tempuser
			return client.Authorized
		}
	}
	return client.Authorized
}
func (database *Database) HandleSocket(client *Client) {
	defer client.Connection.Close()
	strRemoteAddr := client.Connection.RemoteAddr().String()
	input, err := bufio.NewReader(client.Connection).ReadString('\n')
	if err != nil {
		database.config.logger("Read from socket error : "+err.Error(), 2)
		return
	}
	inputFields := strings.Fields(input)
	if len(inputFields) >= 2 {
		if inputFields[1] == "ping" {
			_, err := client.Connection.Write([]byte("pong\n"))
			if err != nil {
				database.config.logger("Error on writing to connection", 1)
			}
			return
		}
		if inputFields[1] == "status" {
			status := ""
			if database.config.Cluster.Master == "true" {
				status = database.cluster.GetStatus()
			} else {
				status = "Not Clustered"
			}
			_, err := client.Connection.Write([]byte(status+"\n"))
			if err != nil {
				database.config.logger("Error on writing to connection", 1)
			}
			return
		}
		if inputFields[1] == "exit" {
			database.config.logger("Client closed the connection from "+strRemoteAddr, 2)
			return
		}
		if inputFields[1] == "EOF" {
			database.config.logger("Client terminated the connection from "+strRemoteAddr, 2)
			return
		}
	}
	if database.config.Acl.Authorization == "true" {
		if client.Validate(inputFields[0], database.config) {
			cmd := ""
			if len(inputFields) >= 3 {
				cmd = inputFields[1]
				for n := 2; n < len(inputFields); n++ {
					cmd += " " + inputFields[n]
				}
			}
			returneddb, message := database.cmd(cmd, &client.User)
			jsondb, err := json.Marshal(returneddb.items)
			if message != "" {
				_, err := client.Connection.Write([]byte(message+"\n"))
				if err != nil {
					database.config.logger("Error on writing to connection", 1)
				}
			}
			if err != nil {
				database.config.logger("Error in converting to json : "+err.Error(), 1)
			}
			if len(jsondb) > 2 {
				_, err := client.Connection.Write([]byte(string(jsondb)+"\n"))
				if err != nil {
					database.config.logger("Error on writing to connection", 1)
				}
			}
		} else {
			database.config.logger("Wrong token "+strRemoteAddr, 1)
			_ = client.Connection.Close()
		}
	} else {
		cmd := ""
		if len(inputFields) >= 3 {
			cmd = inputFields[1]
			for n := 2; n < len(inputFields); n++ {
				cmd += " " + inputFields[n]
			}
		}
		returneddb, message := database.cmd(cmd, &client.User)
		jsondb, err := json.Marshal(returneddb.items)
		if message != "" {
			_, err := client.Connection.Write([]byte(message+"\n"))
			if err != nil {
				database.config.logger("Error on writing to connection", 1)
			}
		}
		if err != nil {
			database.config.logger("Error in converting to json : "+err.Error(), 1)
		}
		if len(jsondb) > 2 {
			_, err := client.Connection.Write([]byte(string(jsondb)+"\n"))
			if err != nil {
				database.config.logger("Error on writing to connection", 1)
			}
		}
	}
}