88 "os"
99 "runtime"
1010
11- // Backend Side-Effect imports
11+ // Backend Side-Effect imports, ie load the providers into registry but
12+ // config will determine if they get used.
13+ // if you are building custom daemon, you can cherry pick sources you care about
1214 _ "github.com/dataux/dataux/backends/bigtable"
1315 _ "github.com/dataux/dataux/backends/cassandra"
1416 _ "github.com/dataux/dataux/backends/datastore"
@@ -33,24 +35,29 @@ var (
3335
3436func init () {
3537 flag .StringVar (& configFile , "config" , "dataux.conf" , "dataux proxy config file" )
36- flag .StringVar (& logLevel , "loglevel" , "debug " , "logging [ debug,info,warn,error ]" )
38+ flag .StringVar (& logLevel , "loglevel" , "info " , "logging [ debug,info,warn,error ]" )
3739 flag .StringVar (& pprofPort , "pprof" , ":18008" , "pprof and metrics port" )
3840 flag .IntVar (& workerCt , "workerct" , 3 , "Number of worker nodes" )
3941 flag .Parse ()
4042}
4143func main () {
4244
4345 runtime .GOMAXPROCS (runtime .NumCPU ())
44-
45- if len (configFile ) == 0 {
46- u .Errorf ("must use a config file" )
47- return
48- }
4946 u .SetupLogging (logLevel )
5047 u .SetColorIfTerminal ()
5148
52- proxy .LoadConfig (configFile )
49+ // First try to look for dataux.conf or provided conf file
50+ // if that fails then use the empty default which means api's
51+ // etc can be used to dynamically define schema etc
52+ _ , err := proxy .LoadConfig (configFile )
53+ if err != nil {
54+ _ , err = proxy .LoadConfigString (DefaultConfig )
55+ if err != nil {
56+ os .Exit (1 )
57+ }
58+ }
5359
60+ // go profiling
5461 if pprofPort != "" {
5562 conn , err := net .Listen ("tcp" , pprofPort )
5663 if err != nil {
@@ -67,3 +74,14 @@ func main() {
6774
6875 proxy .RunDaemon (true , workerCt )
6976}
77+
78+ var DefaultConfig = `
79+
80+ frontends : [
81+ {
82+ type : mysql
83+ address : "0.0.0.0:4000"
84+ }
85+ ]
86+
87+ `
0 commit comments