Skip to content

Commit

Permalink
Add server and cli main files
Browse files Browse the repository at this point in the history
Co-authored-by: Anirudh M <m.anirudh18@gmail.com>
  • Loading branch information
olttwa and anirudhmurali committed Jun 14, 2019
1 parent 8343952 commit f3beccf
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cli
server


homebrew-gojek
scripts/proctor.rb
_output/*
Expand Down
18 changes: 18 additions & 0 deletions exec/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"proctor/cmd"
"proctor/config"
"proctor/daemon"
"proctor/io"
"proctor/cmd/version/github"
)

func main() {
printer := io.GetPrinter()
proctorConfigLoader := config.NewLoader()
proctorDClient := daemon.NewClient(printer, proctorConfigLoader)
githubClient := github.NewClient()

cmd.Execute(printer, proctorDClient, githubClient)
}
65 changes: 65 additions & 0 deletions exec/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package main

import (
"os"

"github.com/getsentry/raven-go"
"github.com/urfave/cli"

"proctor/proctord/config"
"proctor/proctord/logger"
"proctor/proctord/scheduler"
"proctor/proctord/server"
"proctor/proctord/storage/postgres"
)

func main() {
logger.Setup()
raven.SetDSN(config.SentryDSN())

proctord := cli.NewApp()
proctord.Name = "proctord"
proctord.Usage = "Handle executing jobs and maintaining their configuration"
proctord.Version = "0.2.0"
proctord.Commands = []cli.Command{
{
Name: "migrate",
Description: "Run database migrations for proctord",
Action: func(c *cli.Context) {
err := postgres.Up()
if err != nil {
panic(err.Error())
}
logger.Info("Migration successful")
},
},
{
Name: "rollback",
Description: "Rollback database migrations by one step for proctord",
Action: func(c *cli.Context) {
err := postgres.DownOneStep()
if err != nil {
panic(err.Error())
}
logger.Info("Rollback successful")
},
},
{
Name: "start",
Aliases: []string{"s"},
Usage: "starts server",
Action: func(c *cli.Context) error {
return server.Start()
},
},
{
Name: "start-scheduler",
Usage: "starts scheduler",
Action: func(c *cli.Context) error {
return scheduler.Start()
},
},
}

proctord.Run(os.Args)
}
65 changes: 65 additions & 0 deletions exec/server/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package main

import (
"os"

"github.com/getsentry/raven-go"
"github.com/urfave/cli"

"proctor/proctord/config"
"proctor/proctord/logger"
"proctor/proctord/scheduler"
"proctor/proctord/server"
"proctor/proctord/storage/postgres"
)

func main() {
logger.Setup()
raven.SetDSN(config.SentryDSN())

proctord := cli.NewApp()
proctord.Name = "proctord"
proctord.Usage = "Handle executing jobs and maintaining their configuration"
proctord.Version = "0.2.0"
proctord.Commands = []cli.Command{
{
Name: "migrate",
Description: "Run database migrations for proctord",
Action: func(c *cli.Context) {
err := postgres.Up()
if err != nil {
panic(err.Error())
}
logger.Info("Migration successful")
},
},
{
Name: "rollback",
Description: "Rollback database migrations by one step for proctord",
Action: func(c *cli.Context) {
err := postgres.DownOneStep()
if err != nil {
panic(err.Error())
}
logger.Info("Rollback successful")
},
},
{
Name: "start",
Aliases: []string{"s"},
Usage: "starts server",
Action: func(c *cli.Context) error {
return server.Start()
},
},
{
Name: "start-scheduler",
Usage: "starts scheduler",
Action: func(c *cli.Context) error {
return scheduler.Start()
},
},
}

proctord.Run(os.Args)
}

0 comments on commit f3beccf

Please sign in to comment.