I followed the directions on how to create web applications using Go, and I was able to get an application working great.
One thing I am confused about though is, when you run the application (./8.out), the terminal will sit there and listen on port 8080 until somebody accesses a page.
Does the terminal need to stay up all of the time to run the web application? Does the application act like apache? Does apache need to be run next to this app? Setting this up on a server environment seems very confusing to me right now because I dont understand what the best way to do this is.
EDITED
Thanks for the replies. So if the Go app essentially acts like apache, is there a premade Go server app that has the verboseness of apache?
Does the terminal need to stay up all of the time to run the web application?
If you run it normally from a terminal, then yes. Better options are to run it in the background by adding a “&” to the end of the command line (okay), start it from init (better), or use a process monitor like supervise (best).
Does the application act like apache?
Essentially, yes. It listens for HTTP requests and responds to them.
Does apache need to be run next to this app?
No, the Go application can handle the requests by itself. Some people run apache or some other server on the front end (listening to port 80) and forward requests to their application (listening on port 8080 or some other port) using mod_proxy.
One advantage to doing that are that you can run several different application servers in their own process. For example, you could use Ruby on Rails for the main site, and handle API requests with a Go program.
Another advantage is that your program doesn’t need to be started as root to listen to port 80. You can just run as a normal user without worrying about dropping privileges after you open the connection.
Is there a premade Go server app that has the verboseness of apache?
As far as I know, there are no go servers that would compare to Apache. Go is new enough that it will probably be awhile for something like that.
There are some frameworks that makes it easier to write web applications using the built-in HTTP server though. The only one I’m familiar with is web.go.