You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 2.1 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. _ "google.golang.org/grpc/balancer/grpclb"
  6. "gitlink.org.cn/cloudream/client/internal/cmdline"
  7. "gitlink.org.cn/cloudream/client/internal/config"
  8. "gitlink.org.cn/cloudream/client/internal/services"
  9. coorcli "gitlink.org.cn/cloudream/rabbitmq/client/coordinator"
  10. "gitlink.org.cn/cloudream/utils/ipfs"
  11. log "gitlink.org.cn/cloudream/utils/logger"
  12. )
  13. func main() {
  14. err := config.Init()
  15. if err != nil {
  16. fmt.Printf("init config failed, err: %s", err.Error())
  17. os.Exit(1)
  18. }
  19. err = log.Init(&config.Cfg().Logger)
  20. if err != nil {
  21. fmt.Printf("init logger failed, err: %s", err.Error())
  22. os.Exit(1)
  23. }
  24. coorClient, err := coorcli.NewCoordinatorClient(&config.Cfg().RabbitMQ)
  25. if err != nil {
  26. log.Warnf("new coordinator client failed, err: %s", err.Error())
  27. os.Exit(1)
  28. }
  29. var ipfsCli *ipfs.IPFS
  30. if config.Cfg().IPFS != nil {
  31. log.Infof("IPFS config is not empty, so create a ipfs client")
  32. ipfsCli, err = ipfs.NewIPFS(config.Cfg().IPFS)
  33. if err != nil {
  34. log.Warnf("new ipfs client failed, err: %s", err.Error())
  35. os.Exit(1)
  36. }
  37. }
  38. svc, err := services.NewService(coorClient, ipfsCli)
  39. if err != nil {
  40. log.Warnf("new services failed, err: %s", err.Error())
  41. os.Exit(1)
  42. }
  43. cmds, err := cmdline.NewCommandline(svc)
  44. if err != nil {
  45. log.Warnf("new command line failed, err: %s", err.Error())
  46. os.Exit(1)
  47. }
  48. args := os.Args
  49. cmds.DispatchCommand(args[1], args[2:])
  50. /*
  51. TO DO future:
  52. 1. ls命令,显示用户指定桶下的所有对象,及相关的元数据
  53. 2. rm命令,用户指定bucket和object名,执行删除操作
  54. 3. update命令,用户发起对象更新命令,查询元数据,判断对象的冗余方式,删除旧对象(unpin所有的副本或编码块),写入新对象
  55. 4. ipfsStat命令,查看本地有无ipfsdaemon,ipfs目录的使用率
  56. 5. ipfsFlush命令,unpin本地ipfs目录中的所有cid(block)
  57. 6. 改为交互式client,输入用户名及秘钥后进入交互界面
  58. 7. 支持纯缓存类型的IPFS节点,数据一律存在后端存储服务中
  59. */
  60. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。