working commit
This commit is contained in:
@@ -7,3 +7,5 @@ mstored
|
|||||||
cmd/mstored/mstored
|
cmd/mstored/mstored
|
||||||
cmd/mstorectl/mstorectl
|
cmd/mstorectl/mstorectl
|
||||||
*.db
|
*.db
|
||||||
|
*.db-shm
|
||||||
|
*.db-wal
|
||||||
|
|||||||
+2
-1
@@ -5,7 +5,8 @@ GOFLAGS= -v
|
|||||||
|
|
||||||
sbin_PROGRAMS = mstored
|
sbin_PROGRAMS = mstored
|
||||||
|
|
||||||
mstored_SOURCES = cmd/mstored/mstored.go
|
mstored_SOURCES = cmd/mstored/main.go
|
||||||
|
|
||||||
mstored$(EXEEXT): $(mstored_SOURCES)
|
mstored$(EXEEXT): $(mstored_SOURCES)
|
||||||
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
||||||
|
|
||||||
|
|||||||
+14
-3
@@ -99,7 +99,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
|||||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||||
configure.lineno config.status.lineno
|
configure.lineno config.status.lineno
|
||||||
mkinstalldirs = $(install_sh) -d
|
mkinstalldirs = $(install_sh) -d
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES = app/config/variant.go
|
||||||
CONFIG_CLEAN_VPATH_FILES =
|
CONFIG_CLEAN_VPATH_FILES =
|
||||||
am__installdirs = "$(DESTDIR)$(sbindir)"
|
am__installdirs = "$(DESTDIR)$(sbindir)"
|
||||||
PROGRAMS = $(sbin_PROGRAMS)
|
PROGRAMS = $(sbin_PROGRAMS)
|
||||||
@@ -158,7 +158,8 @@ am__define_uniq_tagged_files = \
|
|||||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
done | $(am__uniquify_input)`
|
done | $(am__uniquify_input)`
|
||||||
AM_RECURSIVE_TARGETS = cscope
|
AM_RECURSIVE_TARGETS = cscope
|
||||||
am__DIST_COMMON = $(srcdir)/Makefile.in config.guess config.sub \
|
am__DIST_COMMON = $(srcdir)/Makefile.in \
|
||||||
|
$(top_srcdir)/app/config/variant.go.in config.guess config.sub \
|
||||||
install-sh missing
|
install-sh missing
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
distdir = $(PACKAGE)-$(VERSION)
|
distdir = $(PACKAGE)-$(VERSION)
|
||||||
@@ -267,6 +268,13 @@ runstatedir = @runstatedir@
|
|||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
srv_confdir = @srv_confdir@
|
||||||
|
srv_datadir = @srv_datadir@
|
||||||
|
srv_devel_mode = @srv_devel_mode@
|
||||||
|
srv_libdir = @srv_libdir@
|
||||||
|
srv_logdir = @srv_logdir@
|
||||||
|
srv_rundir = @srv_rundir@
|
||||||
|
srv_sharedir = @srv_sharedir@
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_build_prefix = @top_build_prefix@
|
top_build_prefix = @top_build_prefix@
|
||||||
@@ -274,7 +282,7 @@ top_builddir = @top_builddir@
|
|||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo
|
AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo
|
||||||
GOFLAGS = -v
|
GOFLAGS = -v
|
||||||
mstored_SOURCES = cmd/mstored/mstored.go
|
mstored_SOURCES = cmd/mstored/main.go
|
||||||
CWD = $(shell pwd)
|
CWD = $(shell pwd)
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
@@ -312,6 +320,8 @@ $(top_srcdir)/configure: $(am__configure_deps)
|
|||||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||||
$(am__aclocal_m4_deps):
|
$(am__aclocal_m4_deps):
|
||||||
|
app/config/variant.go: $(top_builddir)/config.status $(top_srcdir)/app/config/variant.go.in
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $@
|
||||||
install-sbinPROGRAMS: $(sbin_PROGRAMS)
|
install-sbinPROGRAMS: $(sbin_PROGRAMS)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
|
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
|
||||||
@@ -719,6 +729,7 @@ uninstall-am: uninstall-sbinPROGRAMS
|
|||||||
|
|
||||||
.PRECIOUS: Makefile
|
.PRECIOUS: Makefile
|
||||||
|
|
||||||
|
|
||||||
mstored$(EXEEXT): $(mstored_SOURCES)
|
mstored$(EXEEXT): $(mstored_SOURCES)
|
||||||
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
||||||
|
|
||||||
|
|||||||
+13
-5
@@ -2,6 +2,16 @@ package config
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Service Service `json:"service" yaml:"service"`
|
Service Service `json:"service" yaml:"service"`
|
||||||
|
Database Database `json:"database" yaml:"database"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
Address string `json:"address" yaml:"address"`
|
||||||
|
Port int64 `json:"port" yaml:"port"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Database struct {
|
||||||
|
Basepath string `json:"basepath" yaml:"basepath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig() (*Config, error) {
|
func NewConfig() (*Config, error) {
|
||||||
@@ -11,10 +21,8 @@ func NewConfig() (*Config, error) {
|
|||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
Port: 1025,
|
Port: 1025,
|
||||||
},
|
},
|
||||||
|
Database: Database{
|
||||||
|
Basepath: datadir,
|
||||||
|
},
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
Address string `json:"address" yaml:"address"`
|
|
||||||
Port int64 `json:"port" yaml:"port"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
const (
|
||||||
|
confdir = "/home/ziggi/Projects/mstore/etc/mstore"
|
||||||
|
rundir = "/home/ziggi/Projects/mstore/tmp/run"
|
||||||
|
logdir = "/home/ziggi/Projects/mstore/tmp/log"
|
||||||
|
datadir = "/home/ziggi/Projects/mstore/tmp/data"
|
||||||
|
version = "0.1.0"
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
const (
|
||||||
|
confdir = "@srv_confdir@"
|
||||||
|
rundir = "@srv_rundir@"
|
||||||
|
logdir = "@srv_logdir@"
|
||||||
|
datadir = "@srv_datadir@"
|
||||||
|
version = "@PACKAGE_VERSION@"
|
||||||
|
)
|
||||||
@@ -11,4 +11,3 @@ type File struct {
|
|||||||
CreatedBy string `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
CreatedBy string `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
||||||
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ func (hand *Handler) FileExists(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
hand.logg.Debugf("filepath: %s", filepath)
|
hand.logg.Debugf("filepath: %s", filepath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
code, _, _ := hand.oper.FileExists(params)
|
code, _, _ := hand.oper.FileExists(params)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package maindb
|
package maindb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
datapath string
|
datapath string
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package operator
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
//"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
// File exists
|
// File exists
|
||||||
@@ -17,8 +17,8 @@ type FileExistsResult struct{}
|
|||||||
func (oper *Operator) FileExists(param *FileExistsParams) (int, *FileExistsResult, error) {
|
func (oper *Operator) FileExists(param *FileExistsParams) (int, *FileExistsResult, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
filename := path.Base(param.Filepath)
|
//filename := path.Base(param.Filepath)
|
||||||
dirname := path.Dir(filepath)
|
//dirname := path.Dir(filepath)
|
||||||
|
|
||||||
res := &FileExistsResult{}
|
res := &FileExistsResult{}
|
||||||
code := http.StatusOK
|
code := http.StatusOK
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type OperatorParams struct {
|
type OperatorParams struct {
|
||||||
MainDB *database.Database
|
MainDB *maindb.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
type Operator struct {
|
type Operator struct {
|
||||||
maindb *main.Database
|
maindb *maindb.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOperator(params *OperatorParams) (*Operator, error) {
|
func NewOperator(params *OperatorParams) (*Operator, error) {
|
||||||
var err error
|
var err error
|
||||||
oper := &Operator{
|
oper := &Operator{
|
||||||
db: params.MainDB,
|
maindb: params.MainDB,
|
||||||
}
|
}
|
||||||
return oper, err
|
return oper, err
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-5
@@ -12,17 +12,19 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
//"time"
|
//"time"
|
||||||
|
|
||||||
"mstore/app/database"
|
"mstore/app/config"
|
||||||
"mstore/app/handler"
|
"mstore/app/handler"
|
||||||
"mstore/app/logger"
|
"mstore/app/logger"
|
||||||
|
"mstore/app/maindb"
|
||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/service"
|
"mstore/app/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
conf *config.Config
|
||||||
oper *operator.Operator
|
oper *operator.Operator
|
||||||
svc *service.Service
|
svc *service.Service
|
||||||
db *database.Database
|
maindb *maindb.Database
|
||||||
hand *handler.Handler
|
hand *handler.Handler
|
||||||
logg *logger.Logger
|
logg *logger.Logger
|
||||||
}
|
}
|
||||||
@@ -41,21 +43,38 @@ func (srv *Server) Handler() *handler.Handler {
|
|||||||
func (srv *Server) Configure() error {
|
func (srv *Server) Configure() error {
|
||||||
var err error
|
var err error
|
||||||
srv.logg.Infof("Server configure")
|
srv.logg.Infof("Server configure")
|
||||||
|
srv.conf, err = config.NewConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) Build() error {
|
func (srv *Server) Build() error {
|
||||||
var err error
|
var err error
|
||||||
srv.logg.Infof("Server build")
|
srv.logg.Infof("Server build")
|
||||||
|
|
||||||
// Database create
|
// Database create
|
||||||
databaseParams := &database.DatabaseParams{}
|
dbdir := srv.conf.Database.Basepath
|
||||||
srv.db, err = database.NewDatabase(databaseParams)
|
err = os.MkdirAll(srv.conf.Database.Basepath, 0750)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maindb := maindb.NewDatabase(dbdir)
|
||||||
|
err = maindb.OpenDatabase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = maindb.InitDatabase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Operator create
|
// Operator create
|
||||||
operatorParams := &operator.OperatorParams{
|
operatorParams := &operator.OperatorParams{
|
||||||
Database: srv.db,
|
MainDB: srv.maindb,
|
||||||
}
|
}
|
||||||
srv.oper, err = operator.NewOperator(operatorParams)
|
srv.oper, err = operator.NewOperator(operatorParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -615,6 +615,13 @@ PACKAGE_URL=''
|
|||||||
ac_default_prefix=/usr/local
|
ac_default_prefix=/usr/local
|
||||||
ac_subst_vars='LTLIBOBJS
|
ac_subst_vars='LTLIBOBJS
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
srv_datadir
|
||||||
|
srv_libdir
|
||||||
|
srv_sharedir
|
||||||
|
srv_rundir
|
||||||
|
srv_logdir
|
||||||
|
srv_confdir
|
||||||
|
srv_devel_mode
|
||||||
SYSTEMD_FALSE
|
SYSTEMD_FALSE
|
||||||
SYSTEMD_TRUE
|
SYSTEMD_TRUE
|
||||||
LINUX_OS_FALSE
|
LINUX_OS_FALSE
|
||||||
@@ -710,6 +717,13 @@ ac_subst_files=''
|
|||||||
ac_user_opts='
|
ac_user_opts='
|
||||||
enable_option_checking
|
enable_option_checking
|
||||||
enable_silent_rules
|
enable_silent_rules
|
||||||
|
enable_devel_mode
|
||||||
|
with_confdir
|
||||||
|
with_logdir
|
||||||
|
with_rundir
|
||||||
|
with_sharedir
|
||||||
|
with_libdir
|
||||||
|
with_datadir
|
||||||
'
|
'
|
||||||
ac_precious_vars='build_alias
|
ac_precious_vars='build_alias
|
||||||
host_alias
|
host_alias
|
||||||
@@ -1343,6 +1357,18 @@ Optional Features:
|
|||||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||||
--enable-silent-rules less verbose build output (undo: "make V=1")
|
--enable-silent-rules less verbose build output (undo: "make V=1")
|
||||||
--disable-silent-rules verbose build output (undo: "make V=0")
|
--disable-silent-rules verbose build output (undo: "make V=0")
|
||||||
|
--enable-devel-mode Enable developmend mode
|
||||||
|
|
||||||
|
Optional Packages:
|
||||||
|
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||||
|
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||||
|
--with-confdir=PATH set configuration dir to PATH (default:
|
||||||
|
$SRV_CONFDIR)
|
||||||
|
--with-logdir=PATH set path for logdir (default: $SRV_LOGDIR)
|
||||||
|
--with-rundir=PATH set path for rundir (default: $SRV_RUNDIR)
|
||||||
|
--with-sharedir=PATH set share directory (default: $SRV_SHAREDIR)
|
||||||
|
--with-libdir=PATH set lib directory (default: $SRV_LIBDIR)
|
||||||
|
--with-datadir=PATH set path for datadir (default: $SRV_DATADIR)
|
||||||
|
|
||||||
Report bugs to the package provider.
|
Report bugs to the package provider.
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@@ -3062,7 +3088,263 @@ fi
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile"
|
|
||||||
|
test "x$prefix" == "xNONE" && prefix=$ac_default_prefix
|
||||||
|
test "x$libexecdir" == "xNONE" && libexecdir=${prefix}/lib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --enable-devel-mode was given.
|
||||||
|
if test ${enable_devel_mode+y}
|
||||||
|
then :
|
||||||
|
enableval=$enable_devel_mode;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define srv_devel_mode \"false\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_devel_mode="false"
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRCDIR=`pwd`
|
||||||
|
enable_devel_mode=yes
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
SRV_CONFDIR="${prefix}/etc/${PACKAGE}"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-confdir was given.
|
||||||
|
if test ${with_confdir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_confdir; if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_CONFDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-confdir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_CONFDIR="${SRCDIR}/etc/${PACKAGE}"
|
||||||
|
sysconfdir="${SRCDIR}/etc/${PACKAGE}"
|
||||||
|
|
||||||
|
else $as_nop
|
||||||
|
|
||||||
|
test "x$SRV_CONFDIR" == "x/usr/etc/${PACKAGE}" && SRV_CONFDIR="/etc/${PACKAGE}"
|
||||||
|
test "x$prefix" == "x/usr" && sysconfdir="/etc"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_CONFDIR \"$SRV_CONFDIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_confdir="$SRV_CONFDIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_confdir set as ${SRV_CONFDIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_confdir set as ${SRV_CONFDIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
SRV_LOGDIR="/var/log/${PACKAGE}"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-logdir was given.
|
||||||
|
if test ${with_logdir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_logdir; if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_LOGDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-logdir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_LOGDIR="${SRCDIR}/tmp/log"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_LOGDIR \"$SRV_LOGDIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_logdir="$SRV_LOGDIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_logdir set as ${SRV_LOGDIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_logdir set as ${SRV_LOGDIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
SRV_RUNDIR="/var/run/${PACKAGE}"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-rundir was given.
|
||||||
|
if test ${with_rundir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_rundir; if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_RUNDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-rundir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_RUNDIR="${SRCDIR}/tmp/run"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_RUNDIR \"$SRV_RUNDIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_rundir="$SRV_RUNDIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_rundir set as ${SRV_RUNDIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_rundir set as ${SRV_RUNDIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
SRV_SHAREDIR="${prefix}/share/$PACKAGE"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-sharedir was given.
|
||||||
|
if test ${with_sharedir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_sharedir; if test ! -z "$with_sharedir" ; then
|
||||||
|
case $with_sharedir in
|
||||||
|
/*)
|
||||||
|
SRV_SHAREDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-sharedir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_SHAREDIR="${SRCDIR}/share"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_SHAREDIR \"$SRV_SHAREDIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_sharedir="$SRV_SHAREDIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_sharedir set as ${SRV_SHAREDIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_sharedir set as ${SRV_SHAREDIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
SRV_LIBDIR="${prefix}/lib/$PACKAGE"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-libdir was given.
|
||||||
|
if test ${with_libdir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_libdir; if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_LIBDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-libdir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_LIBDIR="${SRCDIR}/sysagent"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_LIBDIR \"$SRV_LIBDIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_libdir="$SRV_LIBDIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_libdir set as ${SRV_LIBDIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_libdir set as ${SRV_LIBDIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SRV_DATADIR="/var/data/${PACKAGE}"
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-datadir was given.
|
||||||
|
if test ${with_datadir+y}
|
||||||
|
then :
|
||||||
|
withval=$with_datadir; if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_DATADIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "You must specify an absolute path to --with-datadir=PATH" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$enable_devel_mode" = "xyes"
|
||||||
|
then :
|
||||||
|
|
||||||
|
SRV_DATADIR="${SRCDIR}/tmp/data"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
printf "%s\n" "#define SRV_DATADIR \"$SRV_DATADIR\"" >>confdefs.h
|
||||||
|
|
||||||
|
srv_datadir="$SRV_DATADIR"
|
||||||
|
|
||||||
|
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: srv_datadir set as ${SRV_DATADIR}" >&5
|
||||||
|
printf "%s\n" "$as_me: srv_datadir set as ${SRV_DATADIR}" >&6;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ac_config_files="$ac_config_files Makefile app/config/variant.go"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# This file is a shell script that caches the results of configure
|
||||||
@@ -3801,6 +4083,7 @@ for ac_config_target in $ac_config_targets
|
|||||||
do
|
do
|
||||||
case $ac_config_target in
|
case $ac_config_target in
|
||||||
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||||
|
"app/config/variant.go") CONFIG_FILES="$CONFIG_FILES app/config/variant.go" ;;
|
||||||
|
|
||||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
+187
@@ -47,7 +47,194 @@ if test -d /lib/systemd/system; then
|
|||||||
AM_CONDITIONAL(SYSTEMD, true)
|
AM_CONDITIONAL(SYSTEMD, true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
test "x$prefix" == "xNONE" && prefix=$ac_default_prefix
|
||||||
|
test "x$libexecdir" == "xNONE" && libexecdir=${prefix}/lib
|
||||||
|
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([devel-mode],
|
||||||
|
AS_HELP_STRING([--enable-devel-mode], [Enable developmend mode]))
|
||||||
|
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(srv_devel_mode, "false", [developmend mode])
|
||||||
|
AC_SUBST(srv_devel_mode, "false")
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRCDIR=`pwd`
|
||||||
|
enable_devel_mode=yes
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SRV_CONFDIR="${prefix}/etc/${PACKAGE}"
|
||||||
|
|
||||||
|
AC_ARG_WITH(confdir,
|
||||||
|
AS_HELP_STRING([--with-confdir=PATH],[set configuration dir to PATH (default: $SRV_CONFDIR)]),
|
||||||
|
[ if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_CONFDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-confdir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi ])
|
||||||
|
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_CONFDIR="${SRCDIR}/etc/${PACKAGE}"
|
||||||
|
sysconfdir="${SRCDIR}/etc/${PACKAGE}"
|
||||||
|
], [
|
||||||
|
test "x$SRV_CONFDIR" == "x/usr/etc/${PACKAGE}" && SRV_CONFDIR="/etc/${PACKAGE}"
|
||||||
|
test "x$prefix" == "x/usr" && sysconfdir="/etc"
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_CONFDIR, "$SRV_CONFDIR", [location of configuration files for ${PACKAGE}])
|
||||||
|
AC_SUBST(srv_confdir, "$SRV_CONFDIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_confdir set as ${SRV_CONFDIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SRV_LOGDIR="/var/log/${PACKAGE}"
|
||||||
|
|
||||||
|
AC_ARG_WITH(logdir,
|
||||||
|
AS_HELP_STRING([--with-logdir=PATH],[set path for logdir (default: $SRV_LOGDIR)]),
|
||||||
|
[ if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_LOGDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-logdir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_LOGDIR="${SRCDIR}/tmp/log"
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_LOGDIR, "$SRV_LOGDIR", [location of ${PACKAGE} logdir])
|
||||||
|
AC_SUBST(srv_logdir, "$SRV_LOGDIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_logdir set as ${SRV_LOGDIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SRV_RUNDIR="/var/run/${PACKAGE}"
|
||||||
|
|
||||||
|
AC_ARG_WITH(rundir,
|
||||||
|
AS_HELP_STRING([--with-rundir=PATH],[set path for rundir (default: $SRV_RUNDIR)]),
|
||||||
|
[ if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_RUNDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-rundir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi ])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_RUNDIR="${SRCDIR}/tmp/run"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_RUNDIR, "$SRV_RUNDIR", [location of rundir])
|
||||||
|
AC_SUBST(srv_rundir, "$SRV_RUNDIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_rundir set as ${SRV_RUNDIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SRV_SHAREDIR="${prefix}/share/$PACKAGE"
|
||||||
|
|
||||||
|
AC_ARG_WITH(sharedir,
|
||||||
|
AS_HELP_STRING([--with-sharedir=PATH],[set share directory (default: $SRV_SHAREDIR)]),
|
||||||
|
[ if test ! -z "$with_sharedir" ; then
|
||||||
|
case $with_sharedir in
|
||||||
|
/*)
|
||||||
|
SRV_SHAREDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-sharedir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi ])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_SHAREDIR="${SRCDIR}/share"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_SHAREDIR, "$SRV_SHAREDIR", [location of share dir])
|
||||||
|
AC_SUBST(srv_sharedir, "$SRV_SHAREDIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_sharedir set as ${SRV_SHAREDIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SRV_LIBDIR="${prefix}/lib/$PACKAGE"
|
||||||
|
|
||||||
|
AC_ARG_WITH(libdir,
|
||||||
|
AS_HELP_STRING([--with-libdir=PATH],[set lib directory (default: $SRV_LIBDIR)]),
|
||||||
|
[ if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_LIBDIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-libdir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi ])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_LIBDIR="${SRCDIR}/sysagent"
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_LIBDIR, "$SRV_LIBDIR", [location of lib dir])
|
||||||
|
AC_SUBST(srv_libdir, "$SRV_LIBDIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_libdir set as ${SRV_LIBDIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SRV_DATADIR="/var/data/${PACKAGE}"
|
||||||
|
|
||||||
|
AC_ARG_WITH(datadir,
|
||||||
|
AS_HELP_STRING([--with-datadir=PATH],[set path for datadir (default: $SRV_DATADIR)]),
|
||||||
|
[ if test ! -z "$withval" ; then
|
||||||
|
case $withval in
|
||||||
|
/*)
|
||||||
|
SRV_DATADIR="$withval"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(You must specify an absolute path to --with-datadir=PATH)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_devel_mode" = "xyes"], [
|
||||||
|
SRV_DATADIR="${SRCDIR}/tmp/data"
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SRV_DATADIR, "$SRV_DATADIR", [location of ${PACKAGE} datadir])
|
||||||
|
AC_SUBST(srv_datadir, "$SRV_DATADIR")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE(srv_datadir set as ${SRV_DATADIR})
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
app/config/variant.go
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-16
@@ -9,13 +9,12 @@ import (
|
|||||||
|
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
"mstore/app/service"
|
|
||||||
//"mstore/pkg/client"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFileExists(t *testing.T) {
|
func MakeServer(t *testing.T) *server.Server {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
srv, err := server.NewServer()
|
srv, err := server.NewServer()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -26,6 +25,15 @@ func TestFileExists(t *testing.T) {
|
|||||||
err = srv.Build()
|
err = srv.Build()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return srv
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFileExists(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
srv := MakeServer(t)
|
||||||
|
require.NotNil(t, srv)
|
||||||
|
|
||||||
reqPath := `/v3/api/file/foo/bare`
|
reqPath := `/v3/api/file/foo/bare`
|
||||||
routePath := `/v3/api/file/{filepath}`
|
routePath := `/v3/api/file/{filepath}`
|
||||||
|
|
||||||
@@ -44,28 +52,24 @@ func TestFileExists(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Printf("Response code: %d\n", recorder.Code)
|
fmt.Printf("Response code: %d\n", recorder.Code)
|
||||||
|
|
||||||
//bodyReader := recorder.Body
|
bodyReader := recorder.Body
|
||||||
//bodyBytes, err := io.ReadAll(bodyReader)
|
bodyBytes, err := io.ReadAll(bodyReader)
|
||||||
|
|
||||||
//fmt.Printf("Response body: %s\n", string(bodyBytes))
|
fmt.Printf("Response body: %s\n", string(bodyBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func xxxTestServiceHello(t *testing.T) {
|
func TestServiceHello(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
srv, err := server.NewServer()
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
err = srv.Configure()
|
srv := MakeServer(t)
|
||||||
require.NoError(t, err)
|
require.NotNil(t, srv)
|
||||||
|
|
||||||
err = srv.Build()
|
reqPath := "/service/hello"
|
||||||
require.NoError(t, err)
|
routePath := "/service/hello"
|
||||||
|
|
||||||
reqPath := service.ServiceHelloPath
|
|
||||||
|
|
||||||
rout := router.NewRouter()
|
rout := router.NewRouter()
|
||||||
hand := srv.Handler()
|
hand := srv.Handler()
|
||||||
rout.Get(reqPath, hand.SendHello)
|
rout.Get(routePath, hand.SendHello)
|
||||||
|
|
||||||
request, err := http.NewRequest("GET", reqPath, nil)
|
request, err := http.NewRequest("GET", reqPath, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user