fix data dir
This commit is contained in:
21
main.go
21
main.go
@@ -1068,7 +1068,7 @@ func performSetup(ctx *deploymentContext) error {
|
|||||||
|
|
||||||
step++
|
step++
|
||||||
printStep(step, totalSetupSteps, "configuring systemd service")
|
printStep(step, totalSetupSteps, "configuring systemd service")
|
||||||
if err := runSSHCommand(ctx.serverIP, systemdScript(ctx.unitServiceDir, ctx.unitEnvFile, ctx.unitVolume, ctx.serviceName)); err != nil {
|
if err := runSSHCommand(ctx.serverIP, systemdScript(ctx.unitServiceDir, ctx.unitEnvFile, ctx.serviceName)); err != nil {
|
||||||
return fmt.Errorf("systemd setup failed: %w", err)
|
return fmt.Errorf("systemd setup failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1557,23 +1557,26 @@ if [ ! -x "$binary" ]; then
|
|||||||
rm -f "$tmp"
|
rm -f "$tmp"
|
||||||
fi
|
fi
|
||||||
env_file="%s"
|
env_file="%s"
|
||||||
data_dir="%s"
|
data_dir="%[5]s"
|
||||||
current_port=""
|
current_port=""
|
||||||
if [ -f "$env_file" ]; then
|
current_data_dir=""
|
||||||
current_port=$(grep '^PORT=' "$env_file" | head -n 1 | cut -d= -f2)
|
if [ -f "$env_file" ]; then
|
||||||
fi
|
current_port=$(grep '^PORT=' "$env_file" | head -n 1 | cut -d= -f2 || true)
|
||||||
|
current_data_dir=$(grep '^POCKETBASE_DATA_DIR=' "$env_file" | head -n 1 | cut -d= -f2 || true)
|
||||||
|
fi
|
||||||
if [ -n "$data_dir" ]; then
|
if [ -n "$data_dir" ]; then
|
||||||
mkdir -p "$data_dir"
|
mkdir -p "$data_dir"
|
||||||
fi
|
fi
|
||||||
if [ "$current_port" != "%d" ]; then
|
if [ "$current_port" != "%d" ] || [ "$current_data_dir" != "%[5]s" ]; then
|
||||||
cat <<'EOF' > "$env_file"
|
cat <<'EOF' > "$env_file"
|
||||||
PORT=%d
|
PORT=%d
|
||||||
|
POCKETBASE_DATA_DIR=%[5]s
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
`, serviceDir, serviceDir, assetURL, envFile, volume, port, port)
|
`, serviceDir, serviceDir, assetURL, envFile, volume, port, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func systemdScript(serviceDir, envFile, volume, serviceName string) string {
|
func systemdScript(serviceDir, envFile, serviceName string) string {
|
||||||
return fmt.Sprintf(`set -euo pipefail
|
return fmt.Sprintf(`set -euo pipefail
|
||||||
cat <<'EOF' > /etc/systemd/system/pb@.service
|
cat <<'EOF' > /etc/systemd/system/pb@.service
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -1591,7 +1594,7 @@ StandardOutput = append:%s/%%i.log
|
|||||||
StandardError = append:%s/%%i.log
|
StandardError = append:%s/%%i.log
|
||||||
WorkingDirectory = %s
|
WorkingDirectory = %s
|
||||||
EnvironmentFile = %s
|
EnvironmentFile = %s
|
||||||
ExecStart = %s/pocketbase serve --dir=%s --http="127.0.0.1:${PORT}"
|
ExecStart = %s/pocketbase serve --dir="${POCKETBASE_DATA_DIR}" --http="127.0.0.1:${PORT}"
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy = multi-user.target
|
WantedBy = multi-user.target
|
||||||
@@ -1599,7 +1602,7 @@ EOF
|
|||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl --no-block enable --now pb@%s
|
systemctl --no-block enable --now pb@%s
|
||||||
systemctl --no-block restart pb@%s
|
systemctl --no-block restart pb@%s
|
||||||
`, serviceDir, serviceDir, serviceDir, envFile, serviceDir, volume, serviceName, serviceName)
|
`, serviceDir, serviceDir, serviceDir, envFile, serviceDir, serviceName, serviceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func systemdRestartScript(serviceName string) string {
|
func systemdRestartScript(serviceName string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user