Custom deployment question

I’ve only recently cracked the ice in developing under grafana, with an experimental fork to enhance the singlestat panel.

I worked through the instructions on ‘Installation/Building Grafana from source’ first in linux and then again in Windows 10 (for anyone new to this, linux is much easier to get working). The only thing I coundn’t get working is the bra run step to automatically rebuild on source changes - no big loss to me, but something someone might want to take a look at.

go get GitHub - unknwon/bra: Bra (Brilliant Ridiculous Assistant) is a command line utility tool.
bra run
(I get “command ‘bra’ not found”, in both linux and windows)
As I said, this is not something I need to worry about.

Where I did get confused though is with the next step to deploy a self-build package. The docs says:

go run build.go build package
It runs then seems to error on the grafana-server build

C:\Users\mdmoo\go\src\github.com\mygrafana\grafana>go run build.go build package
GOPATH is C:\Users\mdmoo\go
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497395954pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=192c447 -X main.buildstamp=1497280620 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=192c447 -X main.buildstamp=1497280620 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
# github.com/mygrafana/grafana/pkg/cmd/grafana-cli
pkg\cmd\grafana-cli\main.go:47: cannot use commands.Commands (type []“github.com/grafana/grafana/vendor/github.com/codegangsta/cli”.Command) as type []“github.com/mygrafana/grafana/vendor/github.com/codegangsta/cli”.Command in assignment
exit status 2
exit status 1

More importantly though, what is a package and how could I use it to (say) do a test install of my fork? It is not at all obvious what needs to be done to create installation-ready binaries for linux and/or windows installs.

Am I missing something?

1 Like

go run build.go build package will give you rpm, deb & tar zip package in dist folder.

Looks like your getting a compile error, maybe wrong go version or GOPATH setting?

Looks like your GOPATH environmental variable or path is not set correctly if go get does not work. GOPATH/bin should be in your path.

Thanks guys - I figured it out in the end. The REAL problem was that my base folder was called "mygrafana’ not plain old “grafana”.

I don’t know if this is by design, or an oversight, but cloning the git repo into any folder other than one called grafana causes an error when running the go run build.go build package command

The full response is this:

go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
# github.com/mygrafana/grafana/pkg/cmd/grafana-cli
pkg\cmd\grafana-cli\main.go:47: cannot use commands.
Commands (type github.com/grafana/grafana/vendor/github.com/codegangsta/cli.Command)
as type github.com/mygrafana/grafana/vendor/github.com/codegangsta/cli.Command
in assignment
exit status 2
exit status 1

after renaming the base folder to grafana, it builds successfully under linux mint
(If anyone is following this, you might need to install the rpmbuild utility too - sudo apt-get install rpm)

Building under Windows is still proving problematic, even after the base folder rename. I’m looking into this and may have an update later. So far, I get this:

C:\Users\mdmoo\go\src\github.com\grafana\grafana>go run build.go build package
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497468241pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
./node_modules/.bin/grunt release --pkgVer=4.4.0-1497468241pre1
‘.’ is not recognized as an internal or external command,
operable program or batch file.
exit status 1
exit status 1

I’ve set the PYTHON environment variable to my Python27 directory (another dependency). So far, I can’t see where the “.” command is coming from.

  • Why didn’t bra work (the command below)? Are you sure your path is set correctly?
go get github.com/Unknwon/bra
bra run
  • By changing grafana to mygrafana you are breaking the go conventions for remote import paths which means that you will not be able to build Grafana. It’s a design decision made by the Go team that has its advantages and disadvantages.

Not sure what you mean about Python? It’s not a Grafana dependency as far as I know anyway…

Do the following commands work on Windows for you?

go run build.go setup
go run build.go build

It’s been a long, strange trip - but the step
yarn install --pure-lockfile
fails, saying

Error: Python executable "C:\Users\mdmoo\AppData\Local\Programs\Python\Python36-32\python.EXE" is v3.6.1, which is not supported by gyp.
The fix (found on Google) is to define the PYTHON environment variable to point to the Python 2 exe.

Yes, these both run with no errors.

grunt also runs with no errors

But go run build.go build package fails, trying to execute the command “.”

c:\Users\mdmoo\go\src\github.com\grafana\grafana>go run build.go build package
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497471716pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.3 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.3 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
./node_modules/.bin/grunt release --pkgVer=4.4.0-1497471716pre1
‘.’ is not recognized as an internal or external command,
operable program or batch file.
exit status 1
exit status 1

[SOLVED]

Setting
PATH=$PATH:$GOPATH/bin

fixes the problem with bra run on windows.

Yes, thought that was what the problem was. Surprised that you got anything to work at all without having $GOPATH/bin in your path.

Oh, had forgotten about node-gyp. When I used node-gyp on Windows I always used it together with Visual Studio rather than Python but it looks like you need both these days: GitHub - nodejs/node-gyp: Node.js native addon build tool

Interesting to know that Grafana has a potential dependency on Python.

OK, after much hair puling etc., I’m finally ready to publish a brand new
panel (michaeldmoore-annunciator-panel) based on SingleStat but with a
number of visual enhancements to work with upper and lower warning and
limit thresholds, suitable for real-time process monitoring etc. of a
simple time series data set.

In future, I’m thinking of adding an optional trend-prediction display so
that users could see when the current rate of change of a monitored value
is expected to exceed one of the limits within some selectable time frame.

I created a pull request on repo.json with (I think) all the required
details. Feel free to critique anything you find problematic - I have a
pretty thick skin :slight_smile:

Also, note that a lot of the code for this panel has been lifted more or
less directly from SingleStat. If this is a problem, or if there are any
additional acknowledgements needed etc., please let me know.

Developing this has been a fun/educational experience and I can anticipate
adding a number of plugins for Grafana in the coming months.

Regards,
Michael Moore

I’m getting the same error as the OP.

$ go version go version go1.9.2 linux/amd64

$ echo $GOPATH /home/jeder/go

$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/sbin:/home/jeder/go/bin

$ go run build.go setup completes successfully

go get github.com/Unknwon/bra bra run also works

But … when I try and build, I get this:

jeder@wks: ~/go/src/grafana (oauth) $ time go run build.go build package
Version: 5.0.0-pre1, Linux Version: 5.0.0, Package Iteration: 1513816735pre1
rm -r dist
rm -r tmp
rm -r /home/jeder/go/pkg/linux_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
go version
go version go1.9.2 linux/amd64
go build -ldflags -w -X main.version=5.0.0-pre1 -X main.commit=43e62b329 -X main.buildstamp=1513816062 -o ./bin/grafana-server ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli
rm -r ./bin/grafana-cli.md5
go version
go version go1.9.2 linux/amd64
go build -ldflags -w -X main.version=5.0.0-pre1 -X main.commit=43e62b329 -X main.buildstamp=1513816062 -o ./bin/grafana-cli ./pkg/cmd/grafana-cli
grafana/pkg/cmd/grafana-cli
pkg/cmd/grafana-cli/main.go:59:15: cannot use commands.Commands (type github.com/grafana/grafana/vendor/github.com/codegangsta/cli”.Command) as type “grafana/vendor/github.com/codegangs
ta/cli”.Command in assignment
exit status 2
exit status 1

1 Like

Are you trying to build the Linux release packages? Or do you just want to the development environment working?

Have you built the frontend and installed the npm packages? The build is failing when trying to build the frontend.

The cli is trying to execute the following and failing:

./node_modules/.bin/grunt release --pkgVer=5.0.0-1513816735pre1

@jeremyeder saw that Dan Cech figured it out on Slack and that you had the Grafana code outside of your Go workspace (very confusing if you are not used to Go :slight_smile: ).

So for anyone else who finds this via Google, it is important to follow this part of the instructions to make sure grafana is installed in the workspace (GOPATH points to the workspace location):

export GOPATH=pwd
go get GitHub - grafana/grafana: The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.