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

Enhancement: dynamic recompilation manager ... ? #26

Closed
jameshfisher opened this issue Apr 23, 2010 · 5 comments
Closed

Enhancement: dynamic recompilation manager ... ? #26

jameshfisher opened this issue Apr 23, 2010 · 5 comments

Comments

@jameshfisher
Copy link

This is (almost) my first experience with web development using a compiled language. I've become extremely used to being able to just change my code, and when I refresh the page, it runs differently. I do this literally more than once a minute.

Compiling a binary every time I want to see a change, even if compilation is almost instantaneous, is hard work. I don't think it's a fundamental issue with compiled languages, though -- how about if some scheme like the following was followed:

The system is aware of the source from which it is compiled, and tracks those files for changes. When a new HTTP request comes in, if changes to the source have been made, it dies, recompiles, starts again, and then handles the request. There'd be issues if you're storing application state in memory, but ... I don't.

I should say, this management would be done by another binary rather than the app itself. Let's call it runwebgo, and I can call it as with any other binary. And let's say for my application, called blog, I provide a plaintext file called .runwebgo, which contains:

  • a list of relative paths to sourcecode files to watch
  • a command to execute when recompilation is required (e.g. make)
  • a port on which my running app will listen

Now, instead of running make and then ./blog every time, I just run runwebgo in the top level of my app directory. runwebgo then:

  • parses my .runwebgo file for the list of files, the command, and the port
  • watches all files for updates, setting a changed flag when a file changes
  • starts up my app
  • runs as a web server (in exactly the same way as a normal web.go app) listening on some odd port (other than the 9999 or 80 which I may have my app configured to)
  • every time a request is received, it checks the changed flag. If things have changed, it kills my app, recompiles it, re-runs it. In either case, it then sends on the request to the port of my app.
  • when it is killed, it kills my app as well.

It could also observe changes to the .runwebgo file itself, and dynamically update the source list if I resave it.

I imagine creating this would not be too hard or use anything outside the standard library. The upshot IMO is massive: I just run one command and leave it for my whole coding session.

@ghost
Copy link

ghost commented Apr 23, 2010

There really is no reason for this to be part of the web.go framework tbh. This sort of stuff belongs to your code environment/IDE.

@jameshfisher
Copy link
Author

I generally dislike bulky IDE solutions. I do realise, though, that there's not really anything specific to web.go here apart from the use case. Is there any current generic tool that will watch do what I describe?

@hoisie
Copy link
Owner

hoisie commented Apr 24, 2010

There was a thread about this on the mailing list:
http://groups.google.com/group/golang-nuts/browse_thread/thread/23b7c1b319adedf

In summary - I'd like to have a 'runwebgo' command but the hard part would be figuring out how to compile the web projct. It would need a generic way to compile go sources. This wouldn't be too hard if there was some kind of config file that describes the structure of the project, but it's this kind of scaffolding that I'm trying to avoid.

@tredoe
Copy link

tredoe commented Jul 4, 2010

@hoisie
Copy link
Owner

hoisie commented Apr 17, 2013

There is still no clean way to automatically recompile apps. Closing for now

@hoisie hoisie closed this as completed Apr 17, 2013
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

3 participants