refactor: cleanup zero'd out processes when a Procfile omitting those process types is set

This change also moves the referenced Procfile out to a host path once on deploy vs potentially several times, which should speed up deploys a small amount and simplify reasoning about the file.

Closes #5112
This commit is contained in:
Jose Diaz-Gonzalez
2022-11-25 00:41:55 -05:00
parent 3100eeb151
commit fe4d80a82b
9 changed files with 139 additions and 166 deletions

View File

@@ -15,12 +15,12 @@ import (
func CatFile(filename string) {
slice, err := FileToSlice(filename)
if err != nil {
LogDebug(fmt.Sprintf("Error cat'ing file %s: %s", filename, err.Error()))
LogWarn(fmt.Sprintf("Error cat'ing file %s: %s", filename, err.Error()))
return
}
for _, line := range slice {
LogDebug(fmt.Sprintf("line: '%s'", line))
LogWarn(fmt.Sprintf("line: '%s'", line))
}
}
@@ -209,6 +209,20 @@ func SetPermissions(path string, fileMode os.FileMode) error {
return os.Chown(path, uid, gid)
}
// TouchFile creates an empty file at the specified path
func TouchFile(filename string) error {
mode := os.FileMode(0600)
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
if err != nil {
return err
}
defer file.Close()
file.Chmod(mode)
SetPermissions(filename, mode)
return nil
}
// WriteSliceToFile writes a slice of strings to a file
func WriteSliceToFile(filename string, lines []string) error {
mode := os.FileMode(0600)