// processStateFromInstance converts a service.Instance into a ProcessState. // It pulls some of its data from empire specific environment variables if they have been set. // Once ECS supports this data natively, we can stop doing this. func processStateFromInstance(i *service.Instance) *ProcessState { createdAt := i.UpdatedAt if t, err := time.Parse(time.RFC3339, i.Process.Env["EMPIRE_CREATED_AT"]); err == nil { createdAt = t } version := i.Process.Env["EMPIRE_RELEASE"] if version == "" { version = "v0" } return &ProcessState{ Name: fmt.Sprintf("%s.%s.%s", version, i.Process.Type, i.ID), Command: i.Process.Command, Constraints: Constraints{ CPUShare: constraints.CPUShare(i.Process.CPUShares), Memory: constraints.Memory(i.Process.MemoryLimit), }, State: i.State, UpdatedAt: createdAt, // This is the best data we have, until ECS gives us UpdatedAt } }
"database/sql" "database/sql/driver" "encoding/json" "fmt" "time" "github.com/jinzhu/gorm" "github.com/lib/pq/hstore" . "github.com/remind101/empire/empire/pkg/bytesize" "github.com/remind101/empire/empire/pkg/constraints" "github.com/remind101/empire/empire/pkg/service" "golang.org/x/net/context" ) var ( Constraints1X = Constraints{constraints.CPUShare(256), constraints.Memory(512 * MB)} Constraints2X = Constraints{constraints.CPUShare(512), constraints.Memory(1 * GB)} ConstraintsPX = Constraints{constraints.CPUShare(1024), constraints.Memory(6 * GB)} // NamedConstraints maps a heroku dynos size to a Constraints. NamedConstraints = map[string]Constraints{ "1X": Constraints1X, "2X": Constraints2X, "PX": ConstraintsPX, } // DefaultConstraints defaults to 1X process size. DefaultConstraints = Constraints1X ) // ProcessQuantityMap represents a map of process types to quantities.