[config] trigger app restart through plugn rather than exec
This commit is contained in:
@@ -48,14 +48,12 @@ func SetMany(appName string, entries map[string]string, restart bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !global && restart && env.GetBoolDefault("DOKKU_APP_RESTORE", true) {
|
if !global && restart && env.GetBoolDefault("DOKKU_APP_RESTORE", true) {
|
||||||
common.LogInfo1(fmt.Sprintf("Restarting app %s", appName))
|
Restart(appName)
|
||||||
cmd := common.NewTokenizedShellCmd("dokku", "ps:restart", appName)
|
|
||||||
cmd.Execute()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unset a value in a config. If appName is empty the global config is used. If restart is true the app is restarted.
|
//UnsetMany a value in a config. If appName is empty the global config is used. If restart is true the app is restarted.
|
||||||
func Unset(appName string, keys []string, restart bool) {
|
func UnsetMany(appName string, keys []string, restart bool) {
|
||||||
global := appName == ""
|
global := appName == ""
|
||||||
env := GetConfig(appName, false)
|
env := GetConfig(appName, false)
|
||||||
var changed = false
|
var changed = false
|
||||||
@@ -72,9 +70,7 @@ func Unset(appName string, keys []string, restart bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !global && restart && env.GetBoolDefault("DOKKU_APP_RESTORE", true) {
|
if !global && restart && env.GetBoolDefault("DOKKU_APP_RESTORE", true) {
|
||||||
common.LogInfo1(fmt.Sprintf("Restarting app %s", appName))
|
Restart(appName)
|
||||||
cmd := common.NewTokenizedShellCmd("dokku", "ps:restart", appName)
|
|
||||||
cmd.Execute()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +121,12 @@ func GetConfig(appName string, merged bool) *configenv.Env {
|
|||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Restart trigger restart on app
|
||||||
|
func Restart(appName string) {
|
||||||
|
common.LogInfo1(fmt.Sprintf("Restarting app %s", appName))
|
||||||
|
common.PlugnTrigger("app-restart", appName)
|
||||||
|
}
|
||||||
|
|
||||||
func loadConfig(appName string) (*configenv.Env, error) {
|
func loadConfig(appName string) (*configenv.Env, error) {
|
||||||
if appName == "" || appName == "--global" {
|
if appName == "" || appName == "--global" {
|
||||||
return configenv.LoadGlobal()
|
return configenv.LoadGlobal()
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ func main() {
|
|||||||
|
|
||||||
args.Parse(os.Args[2:])
|
args.Parse(os.Args[2:])
|
||||||
appName, keys := config.GetCommonArgs(*global, args.Args())
|
appName, keys := config.GetCommonArgs(*global, args.Args())
|
||||||
config.Unset(appName, keys, !*noRestart)
|
config.UnsetMany(appName, keys, !*noRestart)
|
||||||
}
|
}
|
||||||
|
|||||||
14
plugins/ps/app-restart
Executable file
14
plugins/ps/app-restart
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||||
|
|
||||||
|
ps_app_restart() {
|
||||||
|
declare desc="ps app-restart plugin trigger"
|
||||||
|
local trigger="ps_app_restart"
|
||||||
|
local APP="$1";
|
||||||
|
|
||||||
|
ps_restart "$APP"
|
||||||
|
}
|
||||||
|
|
||||||
|
ps_app_restart "$@"
|
||||||
Reference in New Issue
Block a user