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

143 lines
3.1 KiB

  1. package command
  2. import (
  3. "io/ioutil"
  4. "path/filepath"
  5. )
  6. func init() {
  7. cmdScaffold.Run = runScaffold // break init cycle
  8. }
  9. var cmdScaffold = &Command{
  10. UsageLine: "scaffold [filer]",
  11. Short: "generate basic configuration files",
  12. Long: `Generate filer.toml with all possible configurations for you to customize.
  13. `,
  14. }
  15. var (
  16. outputPath = cmdScaffold.Flag.String("output", "", "if not empty, save the configuration file to this directory")
  17. config = cmdScaffold.Flag.String("config", "filer", "the configuration file to generate")
  18. )
  19. func runScaffold(cmd *Command, args []string) bool {
  20. content := ""
  21. switch *config {
  22. case "filer":
  23. content = FILER_TOML_EXAMPLE
  24. }
  25. if content == "" {
  26. println("need a valid -config option")
  27. return false
  28. }
  29. if *outputPath != "" {
  30. ioutil.WriteFile(filepath.Join(*outputPath, *config+".toml"), []byte(content), 0x755)
  31. } else {
  32. println(content)
  33. }
  34. return true
  35. }
  36. const (
  37. FILER_TOML_EXAMPLE = `
  38. # A sample TOML config file for SeaweedFS filer store
  39. [memory]
  40. # local in memory, mostly for testing purpose
  41. enabled = false
  42. [leveldb]
  43. # local on disk, mostly for simple single-machine setup, fairly scalable
  44. enabled = false
  45. dir = "." # directory to store level db files
  46. ####################################################
  47. # multiple filers on shared storage, fairly scalable
  48. ####################################################
  49. [mysql]
  50. # CREATE TABLE IF NOT EXISTS filemeta (
  51. # dirhash BIGINT COMMENT 'first 64 bits of MD5 hash value of directory field',
  52. # name VARCHAR(1000) COMMENT 'directory or file name',
  53. # directory VARCHAR(4096) COMMENT 'full path to parent directory',
  54. # meta BLOB,
  55. # PRIMARY KEY (dirhash, name)
  56. # ) DEFAULT CHARSET=utf8;
  57. enabled = true
  58. hostname = "localhost"
  59. port = 3306
  60. username = "root"
  61. password = ""
  62. database = "" # create or use an existing database
  63. connection_max_idle = 2
  64. connection_max_open = 100
  65. [postgres]
  66. # CREATE TABLE IF NOT EXISTS filemeta (
  67. # dirhash BIGINT,
  68. # name VARCHAR(1000),
  69. # directory VARCHAR(4096),
  70. # meta bytea,
  71. # PRIMARY KEY (dirhash, name)
  72. # );
  73. enabled = false
  74. hostname = "localhost"
  75. port = 5432
  76. username = "postgres"
  77. password = ""
  78. database = "" # create or use an existing database
  79. sslmode = "disable"
  80. connection_max_idle = 100
  81. connection_max_open = 100
  82. [cassandra]
  83. # CREATE TABLE filemeta (
  84. # directory varchar,
  85. # name varchar,
  86. # meta blob,
  87. # PRIMARY KEY (directory, name)
  88. # ) WITH CLUSTERING ORDER BY (name ASC);
  89. enabled = false
  90. keyspace="seaweedfs"
  91. hosts=[
  92. "localhost:9042",
  93. ]
  94. [redis]
  95. enabled = true
  96. address = "localhost:6379"
  97. password = ""
  98. db = 0
  99. [redis_cluster]
  100. enabled = false
  101. addresses = [
  102. "localhost:30001",
  103. "localhost:30002",
  104. "localhost:30003",
  105. "localhost:30004",
  106. "localhost:30005",
  107. "localhost:30006",
  108. ]
  109. ####################################################
  110. # notification
  111. # sends filer updates for each file to an external message queue
  112. ####################################################
  113. [notification.log]
  114. enabled = true
  115. [notification.kafka]
  116. enabled = false
  117. hosts = [
  118. "localhost:9092"
  119. ]
  120. topic = "seaweedfs_filer"
  121. `
  122. )