summaryrefslogtreecommitdiff
path: root/restart.go
blob: 8b2ec793246c62d049ececd536903c5fdc5e4a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// +build !windows

package main

import (
	log "github.com/sirupsen/logrus"
	"os"
	"syscall"
)

func restart() {
	var err error

	if _, err = os.Stat(executable); err != nil {
		log.Fatalf("Error stat executable path, %s", err)
	}

	log.Infof("Re-executing %s...", executable)
	err = syscall.Exec(executable, os.Args, os.Environ())
	if err != nil {
		log.Fatalf("Error re-executing, %s", err)
	}
}