2017-07-19 18:47:01 +01:00
|
|
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
|
|
//
|
|
|
|
// This software (Documize Community Edition) is licensed under
|
|
|
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
//
|
|
|
|
// You can operate outside the AGPL restrictions by purchasing
|
|
|
|
// Documize Enterprise Edition and obtaining a commercial license
|
|
|
|
// by contacting <sales@documize.com>.
|
|
|
|
//
|
|
|
|
// https://documize.com
|
|
|
|
|
|
|
|
// This package provides Documize as a single executable.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/documize/community/core/env"
|
2017-07-31 18:17:30 +01:00
|
|
|
"github.com/documize/community/domain"
|
2017-07-21 13:39:53 +01:00
|
|
|
"github.com/documize/community/domain/section"
|
2017-07-20 12:30:03 +01:00
|
|
|
"github.com/documize/community/edition/boot"
|
2017-07-19 18:47:01 +01:00
|
|
|
"github.com/documize/community/edition/logging"
|
2017-09-01 14:11:09 +01:00
|
|
|
"github.com/documize/community/embed"
|
2017-07-21 18:14:19 +01:00
|
|
|
"github.com/documize/community/server"
|
2017-09-01 14:11:09 +01:00
|
|
|
"github.com/documize/community/server/web"
|
2017-07-21 18:14:19 +01:00
|
|
|
_ "github.com/go-sql-driver/mysql" // the mysql driver is required behind the scenes
|
2017-07-19 18:47:01 +01:00
|
|
|
)
|
|
|
|
|
2017-07-21 13:39:53 +01:00
|
|
|
var rt env.Runtime
|
|
|
|
|
|
|
|
func main() {
|
2017-07-19 18:47:01 +01:00
|
|
|
// runtime stores server/application level information
|
2017-07-21 13:39:53 +01:00
|
|
|
rt := env.Runtime{}
|
2017-07-19 18:47:01 +01:00
|
|
|
|
|
|
|
// wire up logging implementation
|
2018-01-10 16:07:17 +00:00
|
|
|
rt.Log = logging.NewLogger(false)
|
2017-07-19 18:47:01 +01:00
|
|
|
|
2017-09-01 14:11:09 +01:00
|
|
|
// wire up embedded web assets handler
|
|
|
|
web.Embed = embed.NewEmbedder()
|
|
|
|
|
2017-07-21 18:21:34 +01:00
|
|
|
// product details
|
2017-07-21 13:39:53 +01:00
|
|
|
rt.Product = env.ProdInfo{}
|
|
|
|
rt.Product.Major = "1"
|
2018-02-07 19:16:23 +00:00
|
|
|
rt.Product.Minor = "57"
|
2018-02-19 09:46:04 +00:00
|
|
|
rt.Product.Patch = "1"
|
2017-07-21 13:39:53 +01:00
|
|
|
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
|
|
|
rt.Product.Edition = "Community"
|
|
|
|
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
|
|
|
rt.Product.License = env.License{}
|
|
|
|
rt.Product.License.Seats = 1
|
|
|
|
rt.Product.License.Valid = true
|
|
|
|
rt.Product.License.Trial = false
|
|
|
|
rt.Product.License.Edition = "Community"
|
2017-07-19 18:47:01 +01:00
|
|
|
|
2017-07-26 10:50:26 +01:00
|
|
|
// setup store
|
|
|
|
s := domain.Store{}
|
|
|
|
|
2017-07-20 10:48:27 +01:00
|
|
|
// parse settings from command line and environment
|
2017-07-21 13:39:53 +01:00
|
|
|
rt.Flags = env.ParseFlags()
|
2017-07-26 10:50:26 +01:00
|
|
|
flagsOK := boot.InitRuntime(&rt, &s)
|
2017-07-20 10:48:27 +01:00
|
|
|
|
|
|
|
if flagsOK {
|
|
|
|
// runtime.Log = runtime.Log.SetDB(runtime.Db)
|
|
|
|
}
|
2017-07-19 18:47:01 +01:00
|
|
|
|
2017-07-21 14:11:57 +01:00
|
|
|
// Register smart sections
|
2017-08-02 15:26:31 +01:00
|
|
|
section.Register(&rt, &s)
|
2017-07-19 18:47:01 +01:00
|
|
|
|
2017-07-21 14:11:57 +01:00
|
|
|
ready := make(chan struct{}, 1) // channel signals router ready
|
2017-07-26 10:50:26 +01:00
|
|
|
server.Start(&rt, &s, ready)
|
2017-07-19 18:47:01 +01:00
|
|
|
}
|