Skip to content

Commit a0de4a0

Browse files
committed
feat: ditch rcd for mount processes instead.
1 parent 4e8acff commit a0de4a0

File tree

16 files changed

+270
-1054
lines changed

16 files changed

+270
-1054
lines changed

src/cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ func main() {
2525
sigs := make(chan os.Signal, 1)
2626
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
2727

28-
rclone_manager.InitializeRCD(logger)
28+
rclone_manager.InitializeRClone(logger)
2929

3030
for {
3131
select {
3232
case sig := <-sigs:
3333
logger.Warn().Msgf("Received signal %v, shutting down...", sig)
34-
rclone_manager.StopRcloneRemoteDaemon(logger)
34+
rclone_manager.StopRclone(logger)
3535
os.Exit(0)
3636
default:
3737
time.Sleep(1 * time.Second)

src/go.mod

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,15 @@ go 1.23
44

55
require (
66
github.com/fsnotify/fsnotify v1.8.0
7-
github.com/rclone/rclone v1.68.2
87
github.com/rs/zerolog v1.33.0
98
gopkg.in/yaml.v3 v3.0.1
109
)
1110

1211
require (
13-
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd // indirect
14-
github.com/aalpar/deheap v0.0.0-20210914013432-0cc84d79dec3 // indirect
15-
github.com/abbot/go-http-auth v0.4.0 // indirect
16-
github.com/beorn7/perks v1.0.1 // indirect
17-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
18-
github.com/coreos/go-semver v0.3.1 // indirect
19-
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
20-
github.com/go-chi/chi/v5 v5.1.0 // indirect
21-
github.com/go-git/go-billy/v5 v5.5.0 // indirect
22-
github.com/go-ole/go-ole v1.3.0 // indirect
23-
github.com/google/uuid v1.6.0 // indirect
24-
github.com/inconshreveable/mousetrap v1.1.0 // indirect
25-
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
26-
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
12+
github.com/kr/pretty v0.3.1 // indirect
2713
github.com/mattn/go-colorable v0.1.13 // indirect
2814
github.com/mattn/go-isatty v0.0.20 // indirect
29-
github.com/mitchellh/go-homedir v1.1.0 // indirect
30-
github.com/moby/sys/mountinfo v0.7.2 // indirect
31-
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
32-
github.com/prometheus/client_golang v1.19.1 // indirect
33-
github.com/prometheus/client_model v0.5.0 // indirect
34-
github.com/prometheus/common v0.48.0 // indirect
35-
github.com/prometheus/procfs v0.12.0 // indirect
36-
github.com/rfjakob/eme v1.1.2 // indirect
37-
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
38-
github.com/shoenig/go-m1cpu v0.1.6 // indirect
39-
github.com/sirupsen/logrus v1.9.3 // indirect
40-
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
41-
github.com/smartystreets/goconvey v1.8.1 // indirect
42-
github.com/spf13/cobra v1.8.1 // indirect
43-
github.com/spf13/pflag v1.0.5 // indirect
44-
github.com/tklauser/go-sysconf v0.3.13 // indirect
45-
github.com/tklauser/numcpus v0.7.0 // indirect
46-
github.com/unknwon/goconfig v1.0.0 // indirect
47-
github.com/yusufpapurcu/wmi v1.2.4 // indirect
48-
golang.org/x/crypto v0.25.0 // indirect
49-
golang.org/x/net v0.27.0 // indirect
50-
golang.org/x/sync v0.8.0 // indirect
15+
github.com/rogpeppe/go-internal v1.12.0 // indirect
5116
golang.org/x/sys v0.22.0 // indirect
52-
golang.org/x/term v0.22.0 // indirect
53-
golang.org/x/text v0.17.0 // indirect
54-
golang.org/x/time v0.5.0 // indirect
55-
google.golang.org/protobuf v1.34.2 // indirect
17+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
5618
)

src/go.sum

Lines changed: 6 additions & 385 deletions
Large diffs are not rendered by default.

src/internal/constants/constants.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@ package constants
44
const (
55
Rclone = "rclone"
66
Serve = "serve"
7-
Rcd = "rcd"
8-
Rc = "rc"
9-
Mount = "mount/mount"
10-
UnmountAll = "mount/unmountall"
11-
Unmount = "mount/unmount"
7+
Mount = "mount"
128
MountPoint = "mountPoint="
13-
Fs = "fs="
149
Addr = "--addr"
15-
VfsOpt = "vfsOpt="
16-
MountOpt = "mountOpt="
1710
)
1811

1912
// Constants for fusermount
2013
const (
2114
Fusermount = "fusermount"
22-
FuseUnmount = "-u"
15+
FuseUnmount = "-uz"
2316
)
2417

2518
// Log constants
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package instance_tracker
2+
3+
import (
4+
"os/exec"
5+
"time"
6+
)
7+
8+
type RcloneProcess struct {
9+
PID int
10+
Command *exec.Cmd
11+
BackendName string
12+
StartedAt time.Time
13+
GracePeriod time.Duration
14+
Environment map[string]string
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package instance_tracker
2+
3+
import "sync"
4+
5+
type InstanceTracker[T any] struct {
6+
processMap sync.Map
7+
}
8+
9+
func (t *InstanceTracker[T]) Track(key string, instance *T) {
10+
t.processMap.Store(key, instance)
11+
}
12+
13+
func (t *InstanceTracker[T]) Untrack(key string) {
14+
t.processMap.Delete(key)
15+
}
16+
17+
func (t *InstanceTracker[T]) Range(f func(key, value interface{}) bool) {
18+
t.processMap.Range(f)
19+
}
20+
21+
func (t *InstanceTracker[T]) Get(key string) (*T, bool) {
22+
val, ok := t.processMap.Load(key)
23+
if !ok {
24+
return nil, false
25+
}
26+
instance, valid := val.(*T)
27+
if !valid {
28+
return nil, false
29+
}
30+
return instance, true
31+
}

0 commit comments

Comments
 (0)