Пример #1
0
//Run creates all the structures to make or project work
func Run() {

	//Launch API

	s := server{
		name:        "Elvis",
		ip:          "127.0.0.1",
		port:        4242,
		clientLimit: 10,
	}

	// model.DB, _ = gorm.Open(
	// 	"postgres",
	// 	"dbname=gobox sslmode=disable",
	// )
	// model.DB.AutoMigrate(
	// 	&structs.User{},
	// 	&structs.Client{},
	// 	&structs.FileAction{},
	// 	&structs.File{},
	// 	&structs.FileSystemFile{},
	// )

	err := createDummyUser()
	if err != nil {
		log.Fatal(err)
	}
	////Launch UDP notification service
	////Define the Subject (The guy who is goin to hold all the clients)

	pusher := &UDPush.Pusher{
		ServerID: s.ip,
		BindedTo: s.port,
	}

	go func() {
		err = pusher.InitUDPush()
		if err != nil {
			fmt.Println(err)
		}
	}()
	api.ServeServerRoutes("8000", pusher)
}
Пример #2
0
func init() {
	model.DB, _ = gorm.Open("postgres", "dbname=goboxtest sslmode=disable")

	model.DB.DropTableIfExists(&structs.User{})
	model.DB.DropTableIfExists(&structs.Client{})
	model.DB.DropTableIfExists(&structs.FileAction{})
	model.DB.DropTableIfExists(&structs.File{})
	model.DB.DropTableIfExists(&structs.FileSystemFile{})
	model.DB.AutoMigrate(&structs.User{}, &structs.Client{}, &structs.FileAction{}, &structs.File{}, &structs.FileSystemFile{})

	user, _ = boxtools.NewUser("max.t.mcdonnell@gmail", "password")

	var err error
	client, err = boxtools.NewClient(user, "test", false)
	if err != nil {
		fmt.Println(err)
	}

	apiClient = New(client.SessionKey)

	go server_api.ServeServerRoutes("8000")
}