mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
34 lines
810 B
Go
34 lines
810 B
Go
package procfile
|
|
|
|
import "github.com/railwayapp/railpack/core/generate"
|
|
|
|
type ProcfileProvider struct{}
|
|
|
|
func (p *ProcfileProvider) Name() string {
|
|
return "procfile"
|
|
}
|
|
|
|
func (p *ProcfileProvider) Plan(ctx *generate.GenerateContext) (bool, error) {
|
|
if _, err := ctx.App.ReadFile("Procfile"); err != nil {
|
|
return false, nil
|
|
}
|
|
|
|
parsedProcfile := map[string]string{}
|
|
if err := ctx.App.ReadYAML("Procfile", &parsedProcfile); err != nil {
|
|
return false, err
|
|
}
|
|
|
|
webCommand := parsedProcfile["web"]
|
|
workerCommand := parsedProcfile["worker"]
|
|
|
|
if webCommand != "" {
|
|
ctx.Logger.LogInfo("Found web command in Procfile")
|
|
ctx.Deploy.StartCmd = webCommand
|
|
} else if workerCommand != "" {
|
|
ctx.Logger.LogInfo("Found worker command in Procfile")
|
|
ctx.Deploy.StartCmd = workerCommand
|
|
}
|
|
|
|
return false, nil
|
|
}
|