mirror of
https://github.com/dokku/dokku.git
synced 2026-02-23 19:50:34 +01:00
Merge pull request #6156 from dokku/migrate-lock-path
Migrate the app deploy lock to the data directory
This commit is contained in:
@@ -179,7 +179,7 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||
return common.CloneAppData("app-json", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostCreate ensures apps the correct data directory structure
|
||||
// TriggerPostCreate ensures apps have the correct data directory structure
|
||||
func TriggerPostCreate(appName string) error {
|
||||
return common.CreateAppDataDirectory("app-json", appName)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/unlock
|
||||
TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report
|
||||
TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = apps
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ func appExists(appName string) error {
|
||||
|
||||
// checks if an app is locked
|
||||
func appIsLocked(appName string) bool {
|
||||
lockfilePath := fmt.Sprintf("%v/.deploy.lock", common.AppRoot(appName))
|
||||
_, err := os.Stat(lockfilePath)
|
||||
lockPath := getLockPath(appName)
|
||||
_, err := os.Stat(lockPath)
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
@@ -94,6 +94,11 @@ func destroyApp(appName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// returns the lock path
|
||||
func getLockPath(appName string) string {
|
||||
return fmt.Sprintf("%v/.deploy.lock", common.GetAppDataDirectory("apps", appName))
|
||||
}
|
||||
|
||||
// creates an app if allowed
|
||||
func maybeCreateApp(appName string) error {
|
||||
if err := appExists(appName); err == nil {
|
||||
|
||||
@@ -41,10 +41,17 @@ func main() {
|
||||
oldAppName := flag.Arg(0)
|
||||
newAppName := flag.Arg(1)
|
||||
err = apps.TriggerPostAppCloneSetup(oldAppName, newAppName)
|
||||
case "post-app-rename":
|
||||
oldAppName := flag.Arg(0)
|
||||
newAppName := flag.Arg(1)
|
||||
err = apps.TriggerPostAppRename(oldAppName, newAppName)
|
||||
case "post-app-rename-setup":
|
||||
oldAppName := flag.Arg(0)
|
||||
newAppName := flag.Arg(1)
|
||||
err = apps.TriggerPostAppRenameSetup(oldAppName, newAppName)
|
||||
case "post-create":
|
||||
appName := flag.Arg(0)
|
||||
err = apps.TriggerPostCreate(appName)
|
||||
case "post-delete":
|
||||
appName := flag.Arg(0)
|
||||
err = apps.TriggerPostDelete(appName)
|
||||
|
||||
@@ -108,8 +108,8 @@ func CommandLock(appName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
lockfilePath := fmt.Sprintf("%v/.deploy.lock", common.AppRoot(appName))
|
||||
if _, err := os.Create(lockfilePath); err != nil {
|
||||
lockPath := getLockPath(appName)
|
||||
if _, err := os.Create(lockPath); err != nil {
|
||||
return errors.New("Unable to create deploy lock")
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func CommandUnlock(appName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
lockfilePath := fmt.Sprintf("%v/.deploy.lock", common.AppRoot(appName))
|
||||
lockfilePath := getLockPath(appName)
|
||||
if _, err := os.Stat(lockfilePath); !os.IsNotExist(err) {
|
||||
common.LogWarn("A deploy may be in progress.")
|
||||
common.LogWarn("Removing the app lock will not stop in progress deploys.")
|
||||
|
||||
@@ -43,6 +43,10 @@ func TriggerInstall() error {
|
||||
return fmt.Errorf("Unable to install the apps plugin: %s", err.Error())
|
||||
}
|
||||
|
||||
if err := common.SetupAppData("apps"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
apps, err := common.UnfilteredDokkuApps()
|
||||
if err != nil {
|
||||
return nil
|
||||
@@ -79,7 +83,12 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return common.CloneAppData("apps", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostAppRename removes the old app data
|
||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||
return common.MigrateAppDataDirectory("apps", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostAppRenameSetup renames apps files
|
||||
@@ -92,14 +101,22 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return common.CloneAppData("apps", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostDelete is the apps post-delete plugin trigger
|
||||
// TriggerPostCreate ensures apps have the correct data directory structure
|
||||
func TriggerPostCreate(appName string) error {
|
||||
return common.CreateAppDataDirectory("apps", appName)
|
||||
}
|
||||
|
||||
// TriggerPostDelete destroys the apps data for a given app container
|
||||
func TriggerPostDelete(appName string) error {
|
||||
if err := common.PropertyDestroy("apps", appName); err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
dataErr := common.RemoveAppDataDirectory("apps", appName)
|
||||
propertyErr := common.PropertyDestroy("apps", appName)
|
||||
|
||||
if dataErr != nil {
|
||||
return dataErr
|
||||
}
|
||||
|
||||
return nil
|
||||
return propertyErr
|
||||
}
|
||||
|
||||
@@ -944,7 +944,7 @@ acquire_app_deploy_lock() {
|
||||
declare desc="acquire advisory lock for use in deploys"
|
||||
local APP="$1"
|
||||
local LOCK_TYPE="${2:-waiting}"
|
||||
local APP_DEPLOY_LOCK_FILE="$DOKKU_ROOT/$APP/.deploy.lock"
|
||||
local APP_DEPLOY_LOCK_FILE="$DOKKU_LIB_ROOT/data/apps/$APP/.deploy.lock"
|
||||
local LOCK_WAITING_MSG="$APP currently has a deploy lock in place. Waiting..."
|
||||
local LOCK_FAILED_MSG="$APP currently has a deploy lock in place. Exiting..."
|
||||
|
||||
@@ -954,7 +954,7 @@ acquire_app_deploy_lock() {
|
||||
release_app_deploy_lock() {
|
||||
declare desc="release advisory lock used in deploys"
|
||||
local APP="$1"
|
||||
local APP_DEPLOY_LOCK_FILE="$DOKKU_ROOT/$APP/.deploy.lock"
|
||||
local APP_DEPLOY_LOCK_FILE="$DOKKU_LIB_ROOT/data/apps/$APP/.deploy.lock"
|
||||
|
||||
release_advisory_lock "$APP_DEPLOY_LOCK_FILE"
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||
return common.CloneAppData("logs", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostCreate ensures apps the correct data directory structure
|
||||
// TriggerPostCreate ensures apps have the correct data directory structure
|
||||
func TriggerPostCreate(appName string) error {
|
||||
return common.CreateAppDataDirectory("logs", appName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user