mirror of
https://github.com/databasus/databasus.git
synced 2026-04-06 00:32:03 +02:00
@@ -3,6 +3,7 @@
|
||||
package start
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
@@ -93,7 +94,7 @@ func spawnDaemon(log *slog.Logger) (int, error) {
|
||||
return 0, fmt.Errorf("failed to get working directory: %w", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(execPath, args...)
|
||||
cmd := exec.CommandContext(context.Background(), execPath, args...)
|
||||
cmd.Dir = cwd
|
||||
cmd.Stderr = logFile
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
|
||||
@@ -42,10 +42,10 @@ func AcquireLock(log *slog.Logger) (*os.File, error) {
|
||||
_ = f.Close()
|
||||
|
||||
if pidErr != nil {
|
||||
return nil, fmt.Errorf("Another instance is already running.")
|
||||
return nil, fmt.Errorf("another instance is already running")
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Another instance is already running (PID %d).", pid)
|
||||
return nil, fmt.Errorf("another instance is already running (PID %d)", pid)
|
||||
}
|
||||
|
||||
func ReleaseLock(f *os.File) {
|
||||
@@ -59,7 +59,7 @@ func ReadLockFilePID() (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
return readLockPID(f)
|
||||
}
|
||||
|
||||
@@ -222,6 +222,14 @@ func (c *PostgreWalBackupController) CompleteFullBackupUpload(ctx *gin.Context)
|
||||
return
|
||||
}
|
||||
|
||||
if request.Error == nil && (request.StartSegment == "" || request.StopSegment == "") {
|
||||
ctx.JSON(
|
||||
http.StatusBadRequest,
|
||||
gin.H{"error": "startSegment and stopSegment are required when no error is provided"},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.walService.FinalizeBasebackup(
|
||||
database,
|
||||
request.BackupID,
|
||||
|
||||
@@ -84,7 +84,7 @@ type UploadBasebackupResponse struct {
|
||||
|
||||
type FinalizeBasebackupRequest struct {
|
||||
BackupID uuid.UUID `json:"backupId" binding:"required"`
|
||||
StartSegment string `json:"startSegment" binding:"required"`
|
||||
StopSegment string `json:"stopSegment" binding:"required"`
|
||||
StartSegment string `json:"startSegment"`
|
||||
StopSegment string `json:"stopSegment"`
|
||||
Error *string `json:"error"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user