forked from TrueCloudLab/rclone
mount: run rclone mount in the background - fixes #723
This commit is contained in:
parent
90af7af9a3
commit
ebfeec9fb4
4 changed files with 68 additions and 4 deletions
32
cmd/mountlib/daemon_unix.go
Normal file
32
cmd/mountlib/daemon_unix.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Daemonization interface for Unix variants only
|
||||
|
||||
// +build !windows
|
||||
// +build !darwin cgo
|
||||
|
||||
package mountlib
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/sevlyar/go-daemon"
|
||||
)
|
||||
|
||||
func startBackgroundMode() bool {
|
||||
cntxt := &daemon.Context{}
|
||||
d, err := cntxt.Reborn()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if d != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := cntxt.Release(); err != nil {
|
||||
log.Printf("error encountered while killing daemon: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue