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.

setting.go 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "fmt"
  7. "net/url"
  8. "os"
  9. "os/exec"
  10. "path"
  11. "path/filepath"
  12. "runtime"
  13. "strings"
  14. "time"
  15. "github.com/Unknwon/com"
  16. "github.com/macaron-contrib/oauth2"
  17. "github.com/macaron-contrib/session"
  18. "gopkg.in/ini.v1"
  19. "github.com/gogits/gogs/modules/bindata"
  20. "github.com/gogits/gogs/modules/log"
  21. // "github.com/gogits/gogs/modules/ssh"
  22. )
  23. type Scheme string
  24. const (
  25. HTTP Scheme = "http"
  26. HTTPS Scheme = "https"
  27. FCGI Scheme = "fcgi"
  28. )
  29. type LandingPage string
  30. const (
  31. LANDING_PAGE_HOME LandingPage = "/"
  32. LANDING_PAGE_EXPLORE LandingPage = "/explore"
  33. )
  34. var (
  35. // App settings.
  36. AppVer string
  37. AppName string
  38. AppUrl string
  39. AppSubUrl string
  40. // Server settings.
  41. Protocol Scheme
  42. Domain string
  43. HttpAddr, HttpPort string
  44. DisableSSH bool
  45. SSHPort int
  46. SSHDomain string
  47. OfflineMode bool
  48. DisableRouterLog bool
  49. CertFile, KeyFile string
  50. StaticRootPath string
  51. EnableGzip bool
  52. LandingPageUrl LandingPage
  53. // Security settings.
  54. InstallLock bool
  55. SecretKey string
  56. LogInRememberDays int
  57. CookieUserName string
  58. CookieRememberName string
  59. ReverseProxyAuthUser string
  60. // Database settings.
  61. UseSQLite3 bool
  62. UseMySQL bool
  63. UsePostgreSQL bool
  64. // Webhook settings.
  65. Webhook struct {
  66. QueueLength int
  67. DeliverTimeout int
  68. SkipTLSVerify bool
  69. }
  70. // Repository settings.
  71. RepoRootPath string
  72. ScriptType string
  73. AnsiCharset string
  74. // UI settings.
  75. IssuePagingNum int
  76. // Picture settings.
  77. PictureService string
  78. AvatarUploadPath string
  79. GravatarSource string
  80. DisableGravatar bool
  81. // Log settings.
  82. LogRootPath string
  83. LogModes []string
  84. LogConfigs []string
  85. // Attachment settings.
  86. AttachmentPath string
  87. AttachmentAllowedTypes string
  88. AttachmentMaxSize int64
  89. AttachmentMaxFiles int
  90. AttachmentEnabled bool
  91. // Time settings.
  92. TimeFormat string
  93. // Cache settings.
  94. CacheAdapter string
  95. CacheInternal int
  96. CacheConn string
  97. EnableRedis bool
  98. EnableMemcache bool
  99. // Session settings.
  100. SessionConfig session.Options
  101. // Git settings.
  102. Git struct {
  103. MaxGitDiffLines int
  104. GcArgs []string `delim:" "`
  105. Fsck struct {
  106. Enable bool
  107. Interval int
  108. Args []string `delim:" "`
  109. } `ini:"git.fsck"`
  110. }
  111. // I18n settings.
  112. Langs, Names []string
  113. // Other settings.
  114. ShowFooterBranding bool
  115. // Global setting objects.
  116. Cfg *ini.File
  117. CustomPath string // Custom directory path.
  118. CustomConf string
  119. ProdMode bool
  120. RunUser string
  121. IsWindows bool
  122. HasRobotsTxt bool
  123. )
  124. func init() {
  125. IsWindows = runtime.GOOS == "windows"
  126. log.NewLogger(0, "console", `{"level": 0}`)
  127. }
  128. func ExecPath() (string, error) {
  129. file, err := exec.LookPath(os.Args[0])
  130. if err != nil {
  131. return "", err
  132. }
  133. p, err := filepath.Abs(file)
  134. if err != nil {
  135. return "", err
  136. }
  137. return p, nil
  138. }
  139. // WorkDir returns absolute path of work directory.
  140. func WorkDir() (string, error) {
  141. execPath, err := ExecPath()
  142. if err != nil {
  143. return execPath, err
  144. }
  145. // Note: we don't use path.Dir here because it does not handle case
  146. // which path starts with two "/" in Windows: "//psf/Home/..."
  147. execPath = strings.Replace(execPath, "\\", "/", -1)
  148. i := strings.LastIndex(execPath, "/")
  149. if i == -1 {
  150. return execPath, nil
  151. }
  152. return execPath[:i], nil
  153. }
  154. func forcePathSeparator(path string) {
  155. if strings.Contains(path, "\\") {
  156. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  157. }
  158. }
  159. // NewConfigContext initializes configuration context.
  160. // NOTE: do not print any log except error.
  161. func NewConfigContext() {
  162. workDir, err := WorkDir()
  163. if err != nil {
  164. log.Fatal(4, "Fail to get work directory: %v", err)
  165. }
  166. Cfg, err = ini.Load(bindata.MustAsset("conf/app.ini"))
  167. if err != nil {
  168. log.Fatal(4, "Fail to parse 'conf/app.ini': %v", err)
  169. }
  170. CustomPath = os.Getenv("GOGS_CUSTOM")
  171. if len(CustomPath) == 0 {
  172. CustomPath = path.Join(workDir, "custom")
  173. }
  174. if len(CustomConf) == 0 {
  175. CustomConf = path.Join(CustomPath, "conf/app.ini")
  176. }
  177. if com.IsFile(CustomConf) {
  178. if err = Cfg.Append(CustomConf); err != nil {
  179. log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
  180. }
  181. } else {
  182. log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf)
  183. }
  184. Cfg.NameMapper = ini.AllCapsUnderscore
  185. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log"))
  186. forcePathSeparator(LogRootPath)
  187. sec := Cfg.Section("server")
  188. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gogs: Go Git Service")
  189. AppUrl = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
  190. if AppUrl[len(AppUrl)-1] != '/' {
  191. AppUrl += "/"
  192. }
  193. // Check if has app suburl.
  194. url, err := url.Parse(AppUrl)
  195. if err != nil {
  196. log.Fatal(4, "Invalid ROOT_URL(%s): %s", AppUrl, err)
  197. }
  198. AppSubUrl = strings.TrimSuffix(url.Path, "/")
  199. Protocol = HTTP
  200. if sec.Key("PROTOCOL").String() == "https" {
  201. Protocol = HTTPS
  202. CertFile = sec.Key("CERT_FILE").String()
  203. KeyFile = sec.Key("KEY_FILE").String()
  204. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  205. Protocol = FCGI
  206. }
  207. Domain = sec.Key("DOMAIN").MustString("localhost")
  208. HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  209. HttpPort = sec.Key("HTTP_PORT").MustString("3000")
  210. DisableSSH = sec.Key("DISABLE_SSH").MustBool()
  211. SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain)
  212. SSHPort = sec.Key("SSH_PORT").MustInt(22)
  213. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  214. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  215. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
  216. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  217. switch sec.Key("LANDING_PAGE").MustString("home") {
  218. case "explore":
  219. LandingPageUrl = LANDING_PAGE_EXPLORE
  220. default:
  221. LandingPageUrl = LANDING_PAGE_HOME
  222. }
  223. sec = Cfg.Section("security")
  224. InstallLock = sec.Key("INSTALL_LOCK").MustBool()
  225. SecretKey = sec.Key("SECRET_KEY").String()
  226. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt()
  227. CookieUserName = sec.Key("COOKIE_USERNAME").String()
  228. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").String()
  229. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  230. sec = Cfg.Section("attachment")
  231. AttachmentPath = sec.Key("PATH").MustString("data/attachments")
  232. if !filepath.IsAbs(AttachmentPath) {
  233. AttachmentPath = path.Join(workDir, AttachmentPath)
  234. }
  235. AttachmentAllowedTypes = sec.Key("ALLOWED_TYPES").MustString("image/jpeg|image/png")
  236. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(32)
  237. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(10)
  238. AttachmentEnabled = sec.Key("ENABLE").MustBool(true)
  239. TimeFormat = map[string]string{
  240. "ANSIC": time.ANSIC,
  241. "UnixDate": time.UnixDate,
  242. "RubyDate": time.RubyDate,
  243. "RFC822": time.RFC822,
  244. "RFC822Z": time.RFC822Z,
  245. "RFC850": time.RFC850,
  246. "RFC1123": time.RFC1123,
  247. "RFC1123Z": time.RFC1123Z,
  248. "RFC3339": time.RFC3339,
  249. "RFC3339Nano": time.RFC3339Nano,
  250. "Kitchen": time.Kitchen,
  251. "Stamp": time.Stamp,
  252. "StampMilli": time.StampMilli,
  253. "StampMicro": time.StampMicro,
  254. "StampNano": time.StampNano,
  255. }[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
  256. RunUser = Cfg.Section("").Key("RUN_USER").String()
  257. curUser := os.Getenv("USER")
  258. if len(curUser) == 0 {
  259. curUser = os.Getenv("USERNAME")
  260. }
  261. // Does not check run user when the install lock is off.
  262. if InstallLock && RunUser != curUser {
  263. log.Fatal(4, "Expect user(%s) but current user is: %s", RunUser, curUser)
  264. }
  265. // Determine and create root git repository path.
  266. homeDir, err := com.HomeDir()
  267. if err != nil {
  268. log.Fatal(4, "Fail to get home directory: %v", err)
  269. }
  270. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  271. sec = Cfg.Section("repository")
  272. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gogs-repositories"))
  273. forcePathSeparator(RepoRootPath)
  274. if !filepath.IsAbs(RepoRootPath) {
  275. RepoRootPath = path.Join(workDir, RepoRootPath)
  276. } else {
  277. RepoRootPath = path.Clean(RepoRootPath)
  278. }
  279. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  280. AnsiCharset = sec.Key("ANSI_CHARSET").MustString("")
  281. // UI settings.
  282. IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)
  283. sec = Cfg.Section("picture")
  284. PictureService = sec.Key("SERVICE").In("server", []string{"server"})
  285. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString("data/avatars")
  286. forcePathSeparator(AvatarUploadPath)
  287. if !filepath.IsAbs(AvatarUploadPath) {
  288. AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
  289. }
  290. switch sec.Key("GRAVATAR_SOURCE").MustString("gravatar") {
  291. case "duoshuo":
  292. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  293. default:
  294. GravatarSource = "//1.gravatar.com/avatar/"
  295. }
  296. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  297. if OfflineMode {
  298. DisableGravatar = true
  299. }
  300. if err = Cfg.Section("git").MapTo(&Git); err != nil {
  301. log.Fatal(4, "Fail to map Git settings: %v", err)
  302. }
  303. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  304. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  305. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool()
  306. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  307. }
  308. var Service struct {
  309. ActiveCodeLives int
  310. ResetPwdCodeLives int
  311. RegisterEmailConfirm bool
  312. DisableRegistration bool
  313. ShowRegistrationButton bool
  314. RequireSignInView bool
  315. EnableCacheAvatar bool
  316. EnableNotifyMail bool
  317. EnableReverseProxyAuth bool
  318. EnableReverseProxyAutoRegister bool
  319. DisableMinimumKeySizeCheck bool
  320. }
  321. func newService() {
  322. sec := Cfg.Section("service")
  323. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  324. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  325. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  326. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration)
  327. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  328. Service.EnableCacheAvatar = sec.Key("ENABLE_CACHE_AVATAR").MustBool()
  329. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  330. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  331. Service.DisableMinimumKeySizeCheck = sec.Key("DISABLE_MINIMUM_KEY_SIZE_CHECK").MustBool()
  332. }
  333. var logLevels = map[string]string{
  334. "Trace": "0",
  335. "Debug": "1",
  336. "Info": "2",
  337. "Warn": "3",
  338. "Error": "4",
  339. "Critical": "5",
  340. }
  341. func newLogService() {
  342. log.Info("%s %s", AppName, AppVer)
  343. // Get and check log mode.
  344. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  345. LogConfigs = make([]string, len(LogModes))
  346. for i, mode := range LogModes {
  347. mode = strings.TrimSpace(mode)
  348. sec, err := Cfg.GetSection("log." + mode)
  349. if err != nil {
  350. log.Fatal(4, "Unknown log mode: %s", mode)
  351. }
  352. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  353. // Log level.
  354. levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
  355. Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
  356. validLevels)
  357. level, ok := logLevels[levelName]
  358. if !ok {
  359. log.Fatal(4, "Unknown log level: %s", levelName)
  360. }
  361. // Generate log configuration.
  362. switch mode {
  363. case "console":
  364. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  365. case "file":
  366. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gogs.log"))
  367. os.MkdirAll(path.Dir(logPath), os.ModePerm)
  368. LogConfigs[i] = fmt.Sprintf(
  369. `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  370. logPath,
  371. sec.Key("LOG_ROTATE").MustBool(true),
  372. sec.Key("MAX_LINES").MustInt(1000000),
  373. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  374. sec.Key("DAILY_ROTATE").MustBool(true),
  375. sec.Key("MAX_DAYS").MustInt(7))
  376. case "conn":
  377. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  378. sec.Key("RECONNECT_ON_MSG").MustBool(),
  379. sec.Key("RECONNECT").MustBool(),
  380. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  381. sec.Key("ADDR").MustString(":7020"))
  382. case "smtp":
  383. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
  384. sec.Key("USER").MustString("example@example.com"),
  385. sec.Key("PASSWD").MustString("******"),
  386. sec.Key("HOST").MustString("127.0.0.1:25"),
  387. sec.Key("RECEIVERS").MustString("[]"),
  388. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  389. case "database":
  390. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  391. sec.Key("DRIVER").String(),
  392. sec.Key("CONN").String())
  393. }
  394. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  395. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  396. }
  397. }
  398. func newCacheService() {
  399. CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
  400. if EnableRedis {
  401. log.Info("Redis Enabled")
  402. }
  403. if EnableMemcache {
  404. log.Info("Memcache Enabled")
  405. }
  406. switch CacheAdapter {
  407. case "memory":
  408. CacheInternal = Cfg.Section("cache").Key("INTERVAL").MustInt(60)
  409. case "redis", "memcache":
  410. CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
  411. default:
  412. log.Fatal(4, "Unknown cache adapter: %s", CacheAdapter)
  413. }
  414. log.Info("Cache Service Enabled")
  415. }
  416. func newSessionService() {
  417. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  418. []string{"memory", "file", "redis", "mysql"})
  419. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
  420. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
  421. SessionConfig.CookiePath = AppSubUrl
  422. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool()
  423. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  424. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  425. log.Info("Session Service Enabled")
  426. }
  427. // Mailer represents mail service.
  428. type Mailer struct {
  429. Name string
  430. Host string
  431. From string
  432. User, Passwd string
  433. DisableHelo bool
  434. HeloHostname string
  435. SkipVerify bool
  436. UseCertificate bool
  437. CertFile, KeyFile string
  438. }
  439. type OauthInfo struct {
  440. oauth2.Options
  441. AuthUrl, TokenUrl string
  442. }
  443. // Oauther represents oauth service.
  444. type Oauther struct {
  445. GitHub, Google, Tencent,
  446. Twitter, Weibo bool
  447. OauthInfos map[string]*OauthInfo
  448. }
  449. var (
  450. MailService *Mailer
  451. OauthService *Oauther
  452. )
  453. func newMailService() {
  454. sec := Cfg.Section("mailer")
  455. // Check mailer setting.
  456. if !sec.Key("ENABLED").MustBool() {
  457. return
  458. }
  459. MailService = &Mailer{
  460. Name: sec.Key("NAME").MustString(AppName),
  461. Host: sec.Key("HOST").String(),
  462. User: sec.Key("USER").String(),
  463. Passwd: sec.Key("PASSWD").String(),
  464. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  465. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  466. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  467. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  468. CertFile: sec.Key("CERT_FILE").String(),
  469. KeyFile: sec.Key("KEY_FILE").String(),
  470. }
  471. MailService.From = sec.Key("FROM").MustString(MailService.User)
  472. log.Info("Mail Service Enabled")
  473. }
  474. func newRegisterMailService() {
  475. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  476. return
  477. } else if MailService == nil {
  478. log.Warn("Register Mail Service: Mail Service is not enabled")
  479. return
  480. }
  481. Service.RegisterEmailConfirm = true
  482. log.Info("Register Mail Service Enabled")
  483. }
  484. func newNotifyMailService() {
  485. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  486. return
  487. } else if MailService == nil {
  488. log.Warn("Notify Mail Service: Mail Service is not enabled")
  489. return
  490. }
  491. Service.EnableNotifyMail = true
  492. log.Info("Notify Mail Service Enabled")
  493. }
  494. func newWebhookService() {
  495. sec := Cfg.Section("webhook")
  496. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  497. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  498. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  499. }
  500. func NewServices() {
  501. newService()
  502. newLogService()
  503. newCacheService()
  504. newSessionService()
  505. newMailService()
  506. newRegisterMailService()
  507. newNotifyMailService()
  508. newWebhookService()
  509. // ssh.Listen("2222")
  510. }