The web server for GrowBot Web.
-
Make sure Go is set up (you should have
GOROOTandGOPATHset up appropriately).Don't have Go? Please follow the Go installation instructions.
You should also add
$GOPATH/binto your$PATH. This is so that any self-built binaries (such asgoimports) are easy to run. -
Already have Go set up? Make sure
go versionsays you are running go 1.11 or later. We use the new Go Modules system, so if necessary, follow the Go installation instructions to upgrade.Curious about Go Modules? See the Go Modules wiki page!
-
Make sure your editor is set up correctly. All files should be correctly formatted as per
go fmt.We recommend you to use any of the following extensions with the obvious editors: vscode-go, GoSublime or vim-go. These all run
gofmtwhenever you save a.gofile. (You may find usinggoimportsinstead ofgofmtmore convenient.)If you choose to use Goland, please:
- do not add any IDEA-related workspace folder to Git.
- configure
gofmton save—it is not a default feature. Here are instructions to configuregofmton file save. (This Stack Overflow link has not been tested, so you may find other instructions online that are easier to follow.)
-
Git commits must be clean, atomic, and most importantly, follow the seven sacred rules.
If you have a big commit that needs splitting up, you can use
git add --patch(in short,git add -p) to interactively stage hunks.If you are stuck, please ask for assistance!
-
In your folder of choice run
git clone github.com/teamxiv/growbot-api.If you clone the repository inside your
$GOPATH, make sure the root of the repository is situated at exactly$GOPATH/src/github.com/teamxiv/growbot-api.If you clone the repository anywhere else on your filesystem, the folder does not matter.
-
Run
go get ./...to download dependencies.Once you have the repository cloned, typego mod downloadto download dependencies. Then typego mod verifyto verify that all is OK.If you run into a
command not founderror, please jump to step 1 and re-read the Go installation instructions. -
Now, from any directory, you can run the following command:
go install github.com/teamxiv/growbot-api/cmd/growbot-api.- This will build the command-line program (from
./cmd/growbot-api) to your$GOPATH/bindirectory (in step 1 you should have added this path to your$PATH). - You can now simply type
growbot-apifrom any directory to start the API.
- This will build the command-line program (from
Install postgresql (on macOS)
- Run
brew install postgresql - Read the caveats
- Run
brew services run postgresql(startwill run & also tell postgresql to start on boot, you probably don't want to start it on boot)
Set up permissions
- Run
psql postgresto open a postgres shell - Execute
create role growbot with login;to create agrowbot"role" that is able to log in (so it's basically a user). This user has no password for convenience. - Run
make reset_schemato create a database, give ourgrowbotuser admin permissions ondb growbot_dev, and set the database schema - If you make updates to the database structure: run
make schema.sqlto dump the database schema. It is not a full data dump with all rows.
-
Install Gin (same name, different project).
-
Use the following command, run from the project root. Note that
9999can be any random port as we don't want to use the reverse proxy.config=config.yml gin --notifications -i --path="." -d "cmd/growbot-api" --appPort 8080 --port 9999 --bin "cmd/growbot-api/growbot-api" run main.go
Command line documentation is available by supplying the --help argument. As of 737fa69e9799f8886103180ed318395b8a863c96 the following text is printed:
➜ growbot-api --help
Usage of growbot-api:
-bindaddress
Change value of BindAddress. (default 0.0.0.0:8080)
-loglevel
Change value of LogLevel. (default debug)
Generated environment variables:
CONFIG_BINDADDRESS
CONFIG_LOGLEVEL
flag: help requested
Refer to ./internal/config to see what each of these options mean.
Please note that 0.0.0.0:8080 means "bind to all addresses, port 8080". You should try to connect to your loopback address instead of 0.0.0.0:8080. This is usually 127.0.0.1 or localhost.
Instead of using environment variables or command-line arguments, you can use a YAML, JSON or TOML file.
- Just use the argument names as a data key. See
config.example.ymlas an example. - To use a config file, e.g.
config.yml, set theconfigenvironment variable, like so:config=config.yml growbot-api.
You can use wsc. Just do yarn global add wsc and then wsc -er "ws://localhost:8080/stream/<uuid> should work!
-
uuids are provided bygithub.com/google/uuid.UUIDs will generally be used as the serial number of the robot. User accounts will most likely use an
int64as their primary key.
This software is governed by the license defined in /LICENSE at the root of this repository.