Skip to content

Commit

Permalink
feat: ditch rcd for mount processes instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
iPromKnight committed Jan 6, 2025
1 parent 4e8acff commit a0de4a0
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 1,054 deletions.
4 changes: 2 additions & 2 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

rclone_manager.InitializeRCD(logger)
rclone_manager.InitializeRClone(logger)

for {
select {
case sig := <-sigs:
logger.Warn().Msgf("Received signal %v, shutting down...", sig)
rclone_manager.StopRcloneRemoteDaemon(logger)
rclone_manager.StopRclone(logger)
os.Exit(0)
default:
time.Sleep(1 * time.Second)
Expand Down
44 changes: 3 additions & 41 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,15 @@ go 1.23

require (
github.com/fsnotify/fsnotify v1.8.0
github.com/rclone/rclone v1.68.2
github.com/rs/zerolog v1.33.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd // indirect
github.com/aalpar/deheap v0.0.0-20210914013432-0cc84d79dec3 // indirect
github.com/abbot/go-http-auth v0.4.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/go-chi/chi/v5 v5.1.0 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rfjakob/eme v1.1.2 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/unknwon/goconfig v1.0.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
391 changes: 6 additions & 385 deletions src/go.sum

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions src/internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,15 @@ package constants
const (
Rclone = "rclone"
Serve = "serve"
Rcd = "rcd"
Rc = "rc"
Mount = "mount/mount"
UnmountAll = "mount/unmountall"
Unmount = "mount/unmount"
Mount = "mount"
MountPoint = "mountPoint="
Fs = "fs="
Addr = "--addr"
VfsOpt = "vfsOpt="
MountOpt = "mountOpt="
)

// Constants for fusermount
const (
Fusermount = "fusermount"
FuseUnmount = "-u"
FuseUnmount = "-uz"
)

// Log constants
Expand Down
15 changes: 15 additions & 0 deletions src/internal/instance_tracker/process.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package instance_tracker

import (
"os/exec"
"time"
)

type RcloneProcess struct {
PID int
Command *exec.Cmd
BackendName string
StartedAt time.Time
GracePeriod time.Duration
Environment map[string]string
}
31 changes: 31 additions & 0 deletions src/internal/instance_tracker/tracker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package instance_tracker

import "sync"

type InstanceTracker[T any] struct {
processMap sync.Map
}

func (t *InstanceTracker[T]) Track(key string, instance *T) {
t.processMap.Store(key, instance)
}

func (t *InstanceTracker[T]) Untrack(key string) {
t.processMap.Delete(key)
}

func (t *InstanceTracker[T]) Range(f func(key, value interface{}) bool) {
t.processMap.Range(f)
}

func (t *InstanceTracker[T]) Get(key string) (*T, bool) {
val, ok := t.processMap.Load(key)
if !ok {
return nil, false
}
instance, valid := val.(*T)
if !valid {
return nil, false
}
return instance, true
}
Loading

0 comments on commit a0de4a0

Please sign in to comment.