mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 13:42:17 +01:00
Updating file path location search for config.json
Instead of looking for config.json form current directory when running the program, look for the config.json from the executable running directory. This will allow for calling fail2rest executable from a service w/o getting the "failed to open config: config.json" error.
This commit is contained in:
parent
dec5d521b7
commit
c5a2d036d7
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"github.com/Sean-Der/fail2go"
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
|
@ -21,7 +22,11 @@ type ErrorBody struct {
|
|||
var fail2goConn *fail2go.Conn
|
||||
|
||||
func main() {
|
||||
file, fileErr := os.Open("config.json")
|
||||
|
||||
//Changing path of current running directory to path of running executable for finding the config.json file.
|
||||
//This will allow the creation of a linux service to run fail2rest (ie: service fail2rest start/stop/status)
|
||||
var filePath string = path.Dir(os.Args[0])
|
||||
file, fileErr := os.Open(filePath + "/config.json")
|
||||
|
||||
if fileErr != nil {
|
||||
fmt.Println("failed to open config:", fileErr)
|
||||
|
|
Loading…
Reference in a new issue