Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run the GUI ? #5

Closed
joe-getcouragenow opened this issue Jul 31, 2020 · 4 comments
Closed

How to run the GUI ? #5

joe-getcouragenow opened this issue Jul 31, 2020 · 4 comments

Comments

@joe-getcouragenow
Copy link
Contributor

Am trying to work on the github actions for local and github builds.

I build with make build.

But am having trouble running the system itself.


➜  cityaq git:(master) ✗ make server-run
# The GUI is packed into the Server assets.go file, so just run the Server.
cd /Users/apple/workspace/go/src/github.com/ctessum/cityaq && go run ./cmd .
INFO[2020-07-31T09:10:40.007874+02:00] Serving on https://localhost:10000           
2020/07/31 09:10:42 http: TLS handshake error from 127.0.0.1:62448: remote error: tls: unknown certificate
2020/07/31 09:10:42 http: TLS handshake error from 127.0.0.1:62454: remote error: tls: unknown certificate
2020/07/31 09:10:42 http: TLS handshake error from 127.0.0.1:62456: remote error: tls: unknown certificate
INFO[2020-07-31T09:10:42.734318+02:00] cityaq static request                         url=/gui/html addr="127.0.0.1:62458"
INFO[2020-07-31T09:10:48.103292+02:00] cityaq static request                         addr="127.0.0.1:62458" url=/
INFO[2020-07-31T09:10:49.615987+02:00] cityaq static request                         url=/gui/html addr="127.0.0.1:62458"

Neither paths in the browser work for me:

https://localhost:10000/index.html

https://localhost:10000/gui/html

Any tips ?

@ctessum
Copy link
Owner

ctessum commented Jul 31, 2020

It looks like the embedded files in assets.go are now referenced to absolute locations on your computer:

func usersAppleWorkspaceGoSrcGithubComCtessumCityaqGuiHtmlIndexHtmlBytes() ([]byte, error) {
	return bindataRead(
		_usersAppleWorkspaceGoSrcGithubComCtessumCityaqGuiHtmlIndexHtml,
		"Users/apple/workspace/go/src/github.com/ctessum/cityaq/gui/html/index.html",
	)
}

However, the program is expecting index.html to be embedded with the relative path gui/html/index.html. So it is not able to find the embedded index.html. (When I try it I get a 404 error, let me know if you're getting something else.)

It looks like the root of the problem has to do with using LIB_FSPATH in the makefile, therefore making everything run from absolute paths rather than relative paths.

Now that I've actually tested it, the makefile doesn't work at all for me, because I don't keep the code in $GOPATH (with modules, that isn't necessary or even recommended, as far as I know). So is there a way that we can change the makefile to use relative paths?

@joe-getcouragenow
Copy link
Contributor Author

joe-getcouragenow commented Aug 1, 2020

thanks for looking into this.

One thing that does not make sense of the top of my head is that the whole point of go modules is that the path on disk has no effect. So it should not matter where it is compiled from on the disk. The go.mod is the one that essentially declares that this code relates to this golang namespace.

LIB_FSPATH is just a thing i tend to do for projects. We can remove it as we have a makefile in the root of the code now.
I would try that first. What do you think ?

Also about the assets.go. Yep your right. To me that is just a bad design, and we should change to using an embedder that is NOT absolute path based. thoughts ?
A long list of candidates :)
golang/go#35950

Correction: we just have to tell go-bindata to strip the paths prefix ? https://github.com/go-bindata/go-bindata#path-prefix-stripping

@ctessum
Copy link
Owner

ctessum commented Aug 1, 2020

That makes sense. Although, I don't think go-bindata normally uses absolute directories. I think it's some sort of interaction with the way it's called in the makefile, because it worked fine before. So that's why I suspect that removing LIB_FSPATH may fix the problem.

This could be a longer-term fix: https://go.googlesource.com/proposal/+/master/design/draft-embed.md. But it's not ready yet I don't think.

@joe-getcouragenow
Copy link
Contributor Author

fixed with #6

Yes your were right.. Just get rid of the absolute path and all is well. Sorry about that..

I ran the server and the Browser worked for me. Did not test further though as i was in a rush to just get it all holding together on a Sunday.

On Monday will start to actually explore the way things really work more.

@ctessum ctessum closed this as completed Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants