summaryrefslogtreecommitdiff
path: root/restart.go
blob: 9066c1668d38d6c04125965869b2630c50c478eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// +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 while stat executable path, %s", err)
		os.Exit(1)
	}

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