func sigKill() {
	if data, err := ioutil.ReadFile("pidfile.pid"); err == nil {
		mainlog.Infof("pid read is %s", data)
		ecmd := exec.Command("kill", string(data))
		_, err = ecmd.Output()
		if err != nil {
			mainlog.Infof("could not sigkill", err)
		}
	} else {
		mainlog.WithError(err).Info("sigKill - Could not read pidfle")
	}
}
shutdown after calling serve()
package main
import (
	"bufio"
	"crypto/tls"
	"encoding/json"
	"errors"
	"io"
	"io/ioutil"
	"math"
	"os"
	"os/exec"
	"runtime"
	"strconv"
	"strings"
	"sync"
	"testing"
	"time"
	"github.com/flashmob/go-guerrilla"
	"github.com/flashmob/go-guerrilla/backends"
	"github.com/flashmob/go-guerrilla/log"
	test "github.com/flashmob/go-guerrilla/tests"
	"github.com/flashmob/go-guerrilla/tests/testcert"
	"github.com/spf13/cobra"
)
var configJsonA = `
{
    "log_file" : "../../tests/testlog",
    "log_level" : "debug",
    "pid_file" : "./pidfile.pid",
    "allowed_hosts": [
      "guerrillamail.com",
      "guerrillamailblock.com",
      "sharklasers.com",
      "guerrillamail.net",
      "guerrillamail.org"
    ],
    "backend_config": {
    	"save_workers_size" : 1,
    	"save_process": "HeadersParser|Debugger",
        "log_received_mails": true
    },
    "servers" : [
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:3536",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":true,
            	"tls_always_on":false
			}
        },
        {
            "is_enabled" : false,
            "host_name":"enable.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:2228",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
				"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":true,
            	"tls_always_on":false
			}
        }
    ]
}
`
var configJsonB = `
{
    "log_file" : "../../tests/testlog",
    "log_level" : "debug",
    "pid_file" : "./pidfile2.pid",
    "allowed_hosts": [
      "guerrillamail.com",
      "guerrillamailblock.com",
      "sharklasers.com",
      "guerrillamail.net",
      "guerrillamail.org"
    ],
    "backend_config": {
    	"save_workers_size" : 1,
    	"save_process": "HeadersParser|Debugger",
        "log_received_mails": false
    },
    "servers" : [
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:3536",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
            	"start_tls_on":true,
            	"tls_always_on":false
			}
        }
    ]
}
`
var configJsonC = `
{
    "log_file" : "../../tests/testlog",
    "log_level" : "debug",
    "pid_file" : "./pidfile.pid",
    "allowed_hosts": [
      "guerrillamail.com",
      "guerrillamailblock.com",
      "sharklasers.com",
      "guerrillamail.net",
      "guerrillamail.org"
    ],
    "backend_config" :
        {
            "sql_driver": "mysql",
            "sql_dsn": "root:ok@tcp(127.0.0.1:3306)/gmail_mail?readTimeout=10s&writeTimeout=10s",
            "mail_table":"new_mail",
            "redis_interface" : "127.0.0.1:6379",
            "redis_expire_seconds" : 7200,
            "save_workers_size" : 3,
            "primary_mail_host":"sharklasers.com",
            "save_workers_size" : 1,
	    	"save_process": "HeadersParser|Debugger",
	    	"log_received_mails": true
        },
    "servers" : [
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:25",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":true,
            	"tls_always_on":false
			}
        },
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size":1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:465",
            "max_clients":200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":false,
            	"tls_always_on":true
			}
        }
    ]
}
`
var configJsonD = `
{
    "log_file" : "../../tests/testlog",
    "log_level" : "debug",
    "pid_file" : "./pidfile.pid",
    "allowed_hosts": [
      "guerrillamail.com",
      "guerrillamailblock.com",
      "sharklasers.com",
      "guerrillamail.net",
      "guerrillamail.org"
    ],
    "backend_config": {
        "save_workers_size" : 1,
    	"save_process": "HeadersParser|Debugger",
        "log_received_mails": false
    },
    "servers" : [
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:2552",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":true,
            	"tls_always_on":false
			}
        },
        {
            "is_enabled" : true,
            "host_name":"secure.test.com",
            "max_size":1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:4655",
            "max_clients":200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
				"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":false,
            	"tls_always_on":true
			}
        }
    ]
}
`
var configJsonE = `
{
    "log_file" : "../../tests/testlog",
    "log_level" : "debug",
    "pid_file" : "./pidfile2.pid",
    "allowed_hosts": [
      "guerrillamail.com",
      "guerrillamailblock.com",
      "sharklasers.com",
      "guerrillamail.net",
      "guerrillamail.org"
    ],
    "backend_config" :
        {
            "save_process_old": "HeadersParser|Debugger|Hasher|Header|Compressor|Redis|MySql",
            "save_process": "GuerrillaRedisDB",
            "log_received_mails" : true,
            "sql_driver": "mysql",
            "sql_dsn": "root:secret@tcp(127.0.0.1:3306)/gmail_mail?readTimeout=10s&writeTimeout=10s",
            "mail_table":"new_mail",
            "redis_interface" : "127.0.0.1:6379",
            "redis_expire_seconds" : 7200,
            "save_workers_size" : 3,
            "primary_mail_host":"sharklasers.com"
        },
    "servers" : [
        {
            "is_enabled" : true,
            "host_name":"mail.test.com",
            "max_size": 1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:2552",
            "max_clients": 200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":true,
            	"tls_always_on":false
			}
        },
        {
            "is_enabled" : true,
            "host_name":"secure.test.com",
            "max_size":1000000,
            "timeout":180,
            "listen_interface":"127.0.0.1:4655",
            "max_clients":200,
            "log_file" : "../../tests/testlog",
			"tls" : {
				"private_key_file":"../../tests/mail2.guerrillamail.com.key.pem",
            	"public_key_file":"../../tests/mail2.guerrillamail.com.cert.pem",
				"start_tls_on":false,
            	"tls_always_on":true
			}
        }
    ]
}
`
const testPauseDuration = time.Millisecond * 1010
func sigHup() {
	if data, err := ioutil.ReadFile("pidfile.pid"); err == nil {
		mainlog.Infof("pid read is %s", data)
		ecmd := exec.Command("kill", "-HUP", string(data))
		_, err = ecmd.Output()
		if err != nil {
			mainlog.Infof("could not SIGHUP", err)
		}
	} else {
		mainlog.WithError(err).Info("sighup - Could not read pidfle")
	}
}