This repository was archived by the owner on Aug 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +48
-9
lines changed Expand file tree Collapse file tree 6 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ package main
22
33import (
44 "fmt"
5+ "os"
6+
57 "github.com/mjpitz/gitfs/cmd"
68 "github.com/spf13/cobra"
7- "os"
89)
910
1011func main () {
@@ -18,6 +19,7 @@ func main() {
1819 "Specify the configuration path" )
1920
2021 rootCmd .AddCommand (cmd .StartCommand )
22+ rootCmd .AddCommand (cmd .StopCommand )
2123
2224 if err := rootCmd .Execute (); err != nil {
2325 fmt .Println (err )
Original file line number Diff line number Diff line change 11package cmd
22
33import (
4- "github.com/sirupsen/logrus"
54 "os"
5+
6+ "github.com/sirupsen/logrus"
67)
78
89var (
Original file line number Diff line number Diff line change 11package cmd
22
33import (
4+ "os"
5+ "os/user"
6+ "strconv"
7+ "strings"
8+
49 "bazil.org/fuse"
510 "bazil.org/fuse/fs"
611 "github.com/mjpitz/gitfs/pkg/clone"
@@ -10,10 +15,6 @@ import (
1015 "github.com/mjpitz/gitfs/pkg/tree"
1116 "github.com/sirupsen/logrus"
1217 "github.com/spf13/cobra"
13- "os"
14- "os/user"
15- "strconv"
16- "strings"
1718)
1819
1920var StartCommand = & cobra.Command {
Original file line number Diff line number Diff line change 1+ package cmd
2+
3+ import (
4+ "os"
5+ "syscall"
6+
7+ "github.com/mjpitz/gitfs/pkg/config"
8+ "github.com/sirupsen/logrus"
9+ "github.com/spf13/cobra"
10+ "golang.org/x/sys/unix"
11+ )
12+
13+ var StopCommand = & cobra.Command {
14+ Use : "stop" ,
15+ Short : "Stops the file system server." ,
16+ Run : func (cmd * cobra.Command , args []string ) {
17+ props := ConfigPath
18+ if len (props ) == 0 {
19+ fail ("missing config file" )
20+ }
21+
22+ cfg , err := config .Load (os .ExpandEnv (props ))
23+ if err != nil {
24+ fail ("failed to parse configuration: %v" , err )
25+ }
26+
27+ mountpoint := os .ExpandEnv (cfg .Mount )
28+
29+ logrus .Infof ("Unmounting %s" , mountpoint )
30+
31+ _ = syscall .Unmount (mountpoint , unix .MNT_FORCE )
32+ // ignore the error since it's likely not mounted
33+ },
34+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ require (
1818 golang.org/x/net v0.0.0-20181220203305-927f97764cc3
1919 golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890
2020 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
21- golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect
21+ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb
2222 google.golang.org/appengine v1.4.0 // indirect
2323 gopkg.in/src-d/go-billy.v4 v4.3.0
2424 gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 // indirect
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ package clone
33import (
44 "crypto/sha256"
55 "encoding/base32"
6+ "os"
7+ "regexp"
8+
69 "github.com/mjpitz/gitfs/pkg/config"
710 "github.com/mjpitz/gitfs/pkg/sync"
811 "github.com/pkg/errors"
@@ -13,8 +16,6 @@ import (
1316 "gopkg.in/src-d/go-git.v4"
1417 "gopkg.in/src-d/go-git.v4/plumbing/cache"
1518 "gopkg.in/src-d/go-git.v4/storage/filesystem"
16- "os"
17- "regexp"
1819)
1920
2021func NewCloner (cfg * config.CloneConfiguration ) * Cloner {
You can’t perform that action at this time.
0 commit comments