Skip to content

Commit

Permalink
modified logging
Browse files Browse the repository at this point in the history
  • Loading branch information
stormcat24 committed Sep 8, 2015
1 parent b2dfac7 commit d90f9a6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"github.com/codegangsta/cli"
"github.com/stormcat24/ecs-formation/logger"
)

var (
Expand All @@ -21,7 +20,5 @@ func PrepareGlobalOptions(c *cli.Context) error {
RetryCount: c.GlobalInt("retry-count"),
}

logger.Main.Infof("retry-count=%d", AppConfig.RetryCount)

return nil
}
76 changes: 39 additions & 37 deletions operation/commands.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package operation

import (
"log"
"os"
"github.com/codegangsta/cli"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/codegangsta/cli"
"github.com/stormcat24/ecs-formation/aws"
"github.com/stormcat24/ecs-formation/bluegreen"
"github.com/stormcat24/ecs-formation/config"
"github.com/stormcat24/ecs-formation/logger"
"github.com/stormcat24/ecs-formation/service"
"github.com/stormcat24/ecs-formation/task"
"strings"
"github.com/str1ngs/ansi/color"
"github.com/stormcat24/ecs-formation/util"
"github.com/stormcat24/ecs-formation/bluegreen"
"github.com/stormcat24/ecs-formation/logger"
"encoding/json"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/str1ngs/ansi/color"
"log"
"os"
"strings"
)

var Commands = []cli.Command{
Expand All @@ -24,22 +25,22 @@ var Commands = []cli.Command{
}

var commandService = cli.Command{
Name: "service",
Name: "service",
Usage: "Manage ECS services on cluster",
Description: `
Manage services on ECS cluster.
`,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "json-output, jo",
Name: "json-output, jo",
Usage: "Output json",
},
},
Action: doService,
}

var commandTask = cli.Command{
Name: "task",
Name: "task",
Usage: "Manage ECS Task Definitions",
Description: `
Manage ECS Task Definitions.
Expand All @@ -48,18 +49,18 @@ var commandTask = cli.Command{
}

var commandBluegreen = cli.Command{
Name: "bluegreen",
Name: "bluegreen",
Usage: "Manage bluegreen deployment on ECS",
Description: `
Manage bluegreen deployment on ECS.
`,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "nodeploy, nd",
Name: "nodeploy, nd",
Usage: "without deployment, only swap load balancer",
},
cli.BoolFlag{
Name: "json-output, jo",
Name: "json-output, jo",
Usage: "Output json",
},
},
Expand All @@ -80,6 +81,8 @@ func assert(err error) {

func doService(c *cli.Context) {

logger.Main.Infof("retry-count=%d", config.AppConfig.RetryCount)

awsManager, err := buildAwsManager()

if err != nil {
Expand Down Expand Up @@ -110,17 +113,15 @@ func doService(c *cli.Context) {
os.Exit(1)
}

if (operation.SubCommand == "apply") {
if operation.SubCommand == "apply" {
clusterController.ApplyServicePlans(plans)
}
}

type Hoge struct {
Param1 string `json:param1`
}

func doTask(c *cli.Context) {

logger.Main.Infof("retry-count=%d", config.AppConfig.RetryCount)

awsManager, err := buildAwsManager()

if err != nil {
Expand Down Expand Up @@ -149,7 +150,7 @@ func doTask(c *cli.Context) {

plans := createTaskPlans(taskController, projectDir)

if (operation.SubCommand == "apply") {
if operation.SubCommand == "apply" {
results, errapp := taskController.ApplyTaskDefinitionPlans(plans)

if errapp != nil {
Expand All @@ -166,6 +167,8 @@ func doTask(c *cli.Context) {

func doBluegreen(c *cli.Context) {

logger.Main.Infof("retry-count=%d", config.AppConfig.RetryCount)

awsManager, err := buildAwsManager()

if err != nil {
Expand Down Expand Up @@ -202,7 +205,7 @@ func doBluegreen(c *cli.Context) {

// cluster check

if (operation.SubCommand == "apply") {
if operation.SubCommand == "apply" {

nodeploy := c.Bool("nodeploy")

Expand Down Expand Up @@ -342,7 +345,6 @@ func createBlueGreenPlans(controller *bluegreen.BlueGreenController, jsonOutput
return bgplans, errbgp
}


jsonItems := []BlueGreenPlanJson{}
for _, bgplan := range bgplans {
util.PrintlnCyan(" Blue:")
Expand Down Expand Up @@ -383,26 +385,26 @@ func createBlueGreenPlans(controller *bluegreen.BlueGreenController, jsonOutput
jsonItems = append(jsonItems, BlueGreenPlanJson{

Blue: BlueGreenServiceJson{
ClusterARN: *bgplan.Blue.CurrentService.ClusterArn,
ClusterARN: *bgplan.Blue.CurrentService.ClusterArn,
AutoScalingGroupARN: *bgplan.Blue.AutoScalingGroup.AutoScalingGroupARN,
Instances: bgplan.Blue.AutoScalingGroup.Instances,
TaskDefinition: *bgplan.Blue.CurrentService.TaskDefinition,
DesiredCount: *bgplan.Blue.CurrentService.DesiredCount,
PendingCount: *bgplan.Blue.CurrentService.PendingCount,
RunningCount: *bgplan.Blue.CurrentService.RunningCount,
Instances: bgplan.Blue.AutoScalingGroup.Instances,
TaskDefinition: *bgplan.Blue.CurrentService.TaskDefinition,
DesiredCount: *bgplan.Blue.CurrentService.DesiredCount,
PendingCount: *bgplan.Blue.CurrentService.PendingCount,
RunningCount: *bgplan.Blue.CurrentService.RunningCount,
},
Green: BlueGreenServiceJson{
ClusterARN: *bgplan.Green.CurrentService.ClusterArn,
ClusterARN: *bgplan.Green.CurrentService.ClusterArn,
AutoScalingGroupARN: *bgplan.Green.AutoScalingGroup.AutoScalingGroupARN,
Instances: bgplan.Green.AutoScalingGroup.Instances,
TaskDefinition: *bgplan.Green.CurrentService.TaskDefinition,
DesiredCount: *bgplan.Green.CurrentService.DesiredCount,
PendingCount: *bgplan.Green.CurrentService.PendingCount,
RunningCount: *bgplan.Green.CurrentService.RunningCount,
Instances: bgplan.Green.AutoScalingGroup.Instances,
TaskDefinition: *bgplan.Green.CurrentService.TaskDefinition,
DesiredCount: *bgplan.Green.CurrentService.DesiredCount,
PendingCount: *bgplan.Green.CurrentService.PendingCount,
RunningCount: *bgplan.Green.CurrentService.RunningCount,
},
PrimaryElb: bgplan.PrimaryElb,
StandbyElb: bgplan.StandbyElb,
Active: active,
Active: active,
})
}

Expand Down Expand Up @@ -471,7 +473,7 @@ func createOperation(args cli.Args) (Operation, error) {
}

return Operation{
SubCommand: sub,
SubCommand: sub,
TargetResource: targetResource,
}, nil
} else {
Expand Down

0 comments on commit d90f9a6

Please sign in to comment.