fix timing
This commit is contained in:
25
main.go
25
main.go
@@ -353,20 +353,23 @@ func shouldConfirmServerConfig(ctx *deploymentContext) (bool, error) {
|
|||||||
return !exists, nil
|
return !exists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureServerConfigConfirmed(ctx *deploymentContext) (*deploymentContext, error) {
|
func ensureServerConfigConfirmed(ctx *deploymentContext) (*deploymentContext, bool, error) {
|
||||||
needsConfirm, err := shouldConfirmServerConfig(ctx)
|
needsConfirm, err := shouldConfirmServerConfig(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
if !needsConfirm {
|
if !needsConfirm {
|
||||||
return ctx, nil
|
return ctx, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := confirmServerConfig(ctx.configPath); err != nil {
|
if err := confirmServerConfig(ctx.configPath); err != nil {
|
||||||
return nil, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
newCtx, err := buildDeploymentContext()
|
||||||
return buildDeploymentContext()
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
return newCtx, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func confirmServerConfig(pbPath string) error {
|
func confirmServerConfig(pbPath string) error {
|
||||||
@@ -1009,7 +1012,7 @@ func runSetup() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, err = ensureServerConfigConfirmed(ctx)
|
ctx, _, err = ensureServerConfigConfirmed(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1080,7 +1083,7 @@ func runDeploy() error {
|
|||||||
defer func() {
|
defer func() {
|
||||||
closeSSHControlMaster(ctx.serverIP)
|
closeSSHControlMaster(ctx.serverIP)
|
||||||
}()
|
}()
|
||||||
var start time.Time
|
start := time.Now()
|
||||||
|
|
||||||
binaryPath := filepath.Join(ctx.serviceDir, "pocketbase")
|
binaryPath := filepath.Join(ctx.serviceDir, "pocketbase")
|
||||||
exists, err := remoteBinaryExists(ctx.serverIP, binaryPath)
|
exists, err := remoteBinaryExists(ctx.serverIP, binaryPath)
|
||||||
@@ -1090,16 +1093,16 @@ func runDeploy() error {
|
|||||||
|
|
||||||
if err != nil || !exists {
|
if err != nil || !exists {
|
||||||
fmt.Println("PocketBase binary missing on remote; running setup")
|
fmt.Println("PocketBase binary missing on remote; running setup")
|
||||||
ctx, err = ensureServerConfigConfirmed(ctx)
|
ctx, prompted, err := ensureServerConfigConfirmed(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if prompted {
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
|
}
|
||||||
if err := performSetup(ctx); err != nil {
|
if err := performSetup(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
start = time.Now()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dirs := []string{"pb_public", "pb_migrations", "pb_hooks"}
|
dirs := []string{"pb_public", "pb_migrations", "pb_hooks"}
|
||||||
|
|||||||
Reference in New Issue
Block a user