Skip to content

Commit

Permalink
Changing install in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
kilgaloon committed Mar 15, 2019
1 parent 7fc4c1f commit e448085
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export GO111MODULE=on
install:
mkdir /etc/leprechaun
mkdir /etc/leprechaun/recipes
cp -r dist/configs /etc/leprechaun/configs
cp dist/configs/config.ini /etc/leprechaun
mkdir /var/run/leprechaun/
mkdir /var/log/leprechaun/
mkdir /var/log/leprechaun/workers.output
Expand Down
13 changes: 4 additions & 9 deletions cmd/leprechaun/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"os"

"github.com/kilgaloon/leprechaun/client"
"github.com/kilgaloon/leprechaun/cron"
"github.com/kilgaloon/leprechaun/daemon"
Expand All @@ -16,11 +14,8 @@ const (
)

func main() {
if os.Args[1] != "help" {
daemon.Srv.AddService(&client.Client{Name: "scheduler"})
daemon.Srv.AddService(&server.Server{Name: "server"})
daemon.Srv.AddService(&cron.Cron{Name: "cron"})
daemon.Srv.Run()
}

daemon.Srv.AddService(&client.Client{Name: "scheduler"})
daemon.Srv.AddService(&server.Server{Name: "server"})
daemon.Srv.AddService(&cron.Cron{Name: "cron"})
daemon.Srv.Run()
}
40 changes: 21 additions & 19 deletions daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,12 @@ func (d *Daemon) Kill() {
}

func init() {
if os.Args[1] == "help" {
help := "\nAvailable commands for leprechaun --cmd='{agent} {command} {args}' \n" +
"====== \n" +
"daemon info - Display basic informations about daemon. \n" +
"daemon kill - Kills process. \n" +
"====== \n" +
"{agent} info - Display basic info about agent.\n" +
"{agent} start - Start agent if its stopped/paused.\n" +
"{agent} stop - Stop agent, note that this will remove everything from memory and starting will rebuild agent from scratch.\n" +
"{agent} pause - Pause agent will not remove everything from memory and if started again it will just continue.\n" +
"{agent} workers:list - Show list of currently active workers for agent and some basic info.\n" +
"{agent} workers:kill {name} - Kill worker that match name provided.\n"

fmt.Println(help)

return
}

var configPath, pidPath *string
var debug *bool
var debug, helpFlag *bool
var pid int

helpFlag = flag.Bool("help", false, "Display helpfull info")

if api.IsAPIRunning() {
resp := Srv.GetInfo()

Expand Down Expand Up @@ -173,6 +157,24 @@ func init() {
cmd := flag.String("cmd", "run", "Send commands to agents and they will respond")
flag.Parse()

if *helpFlag {
help := "\nAvailable commands for leprechaun --cmd='{agent} {command} {args}' \n" +
"====== \n" +
"daemon info - Display basic informations about daemon. \n" +
"daemon kill - Kills process. \n" +
"====== \n" +
"{agent} info - Display basic info about agent.\n" +
"{agent} start - Start agent if its stopped/paused.\n" +
"{agent} stop - Stop agent, note that this will remove everything from memory and starting will rebuild agent from scratch.\n" +
"{agent} pause - Pause agent will not remove everything from memory and if started again it will just continue.\n" +
"{agent} workers:list - Show list of currently active workers for agent and some basic info.\n" +
"{agent} workers:kill {name} - Kill worker that match name provided.\n"

fmt.Println(help)

os.Exit(1)
}

d := new(Daemon)
f, err := os.OpenFile(*pidPath, os.O_RDWR|os.O_CREATE, 0644)
d.PidFile = f
Expand Down

0 comments on commit e448085

Please sign in to comment.