main.go 747 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "log"
  4. "os"
  5. "path/filepath"
  6. "strconv"
  7. // Vendors
  8. "iscsi"
  9. "github.com/Sirupsen/logrus"
  10. "github.com/docker/go-plugins-helpers/volume"
  11. )
  12. // Main
  13. func main() {
  14. debug := os.Getenv("DEBUG")
  15. if ok, _ := strconv.ParseBool(debug); ok {
  16. logrus.SetLevel(logrus.DebugLevel)
  17. }
  18. iSCSI = iscsi.NewISCSIPlugin()
  19. path := "/var/lib/docker"
  20. d, err := newiscsiDriver(path)
  21. if err != nil {
  22. log.Fatal(err)
  23. }
  24. socketPath := "/run/docker/plugins"
  25. if err := os.MkdirAll(socketPath, 0755); err != nil {
  26. logrus.Error(err.Error())
  27. }
  28. socketAddress := filepath.Join(socketPath, "volume-iscsi.sock")
  29. h := volume.NewHandler(d)
  30. logrus.Infof("listening on %s", socketAddress)
  31. logrus.Error(h.ServeUnix(socketAddress, 0))
  32. }