slight speedup
This commit is contained in:
24
deploy.go
24
deploy.go
@@ -382,8 +382,8 @@ ExecStart = %s/pocketbase serve --http="127.0.0.1:${PORT}"
|
||||
WantedBy = multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now pb@%s
|
||||
systemctl restart pb@%s
|
||||
systemctl --no-block enable --now pb@%s
|
||||
systemctl --no-block restart pb@%s
|
||||
`, serviceDir, serviceDir, serviceDir, envFile, serviceDir, serviceName, serviceName)
|
||||
}
|
||||
|
||||
@@ -426,6 +426,7 @@ func runSSHOutput(server, script string) (string, error) {
|
||||
}
|
||||
|
||||
func syncLocalDirectories(server, remoteBase string, dirs []string) error {
|
||||
var toSync []string
|
||||
for _, dir := range dirs {
|
||||
localPath := filepath.Join(".", dir)
|
||||
info, err := os.Stat(localPath)
|
||||
@@ -441,16 +442,21 @@ func syncLocalDirectories(server, remoteBase string, dirs []string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
remotePath := fmt.Sprintf("root@%s:%s/%s", server, remoteBase, dir)
|
||||
toSync = append(toSync, dir+"/")
|
||||
}
|
||||
|
||||
if len(toSync) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
rsyncCmd := rsyncSSHCommand(server)
|
||||
cmd := exec.Command("rsync", "-e", rsyncCmd, "-az", "--delete", localPath+"/", remotePath)
|
||||
remotePath := fmt.Sprintf("root@%s:%s", server, remoteBase)
|
||||
args := append([]string{"-e", rsyncCmd, "-avz", "--delete", "--relative"}, toSync...)
|
||||
args = append(args, remotePath)
|
||||
cmd := exec.Command("rsync", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func rsyncSSHCommand(server string) string {
|
||||
|
||||
Reference in New Issue
Block a user