Liam Staskawicz  committed b108cf2

update readme for new configuration

  • Participants
  • Parent commits a76a9b9

Comments (0)

Files changed (1)

+# devsrvr
 devsrvr is a simple tool to ease local web development in the [Go]( programming language.
 Its main purpose in life is to sit in front of your webapp and automatically recompile it as needed when
 new requests come in, making the edit/reload cycle much quicker and more productive.
-Find the project online at
+Find the project online at []
+## Usage
-devsrvr has a couple expectations (at the moment):
+To use devsrvr, you need to adjust your app to accept a flag called `addr`, which it uses to configure the address it listens on. A simple example looks like:
-* you use gomake to build your project
-* your app listens via http directly (fcgi and others not yet supported)
+    :::go
+    import (
+	    "flag"
+        "net/http"
+    )
-If that works for you, then all that remains is the following:
+    var addr = flag.String("addr", ":9090", "address")
-* create a config file called 'app.json' at the root level of your app, that looks like:
-        {
-            "App": "myapp",
-            "DevServerAddress": "",
-            "AppAddress": "",
-            "StartupTime": 10000000
-        }
-  * __App__ is the name of your app's binary - this is the only required field
-  * __DevServerAddress__ is the address that devsrvr will listen on - this is the one to enter into our browser
-  * __AppAddress__ is the address to connect to your app on - essentially anything different than DevServerAddress is probably fine. Make sure
-  this matches whatever your app is configured to listen on.
-  * __StartupTime__ is an optional field to specify how long to wait (in nanoseconds) before connecting to your app after rebuilding it
-* devsrvr also currently assumes your Makefile is at the root level of your app as well, though that should probably be configurable...
+    func main() {
+        flag.Parse()
+        log.Println("listening on:", *addr)
+        log.Fatal(http.ListenAndServe(*addr, http.HandlerFunc(fooHandler)))
+    }
-Now, navigate to your app's root directory and invoke `devsrvr`. Enter the value you used for 'DevServerAddress' into your browser
-and you should see your app. Make an edit, and reload your browser - magic!
+By default, devsrvr will listen on `localhost:8000`, and instruct your app to listen on `localhost:8888`.
-If you'd like to run devsrvr from another location, pass the root directory of your app as a flag:
-`devsrvr --approot /path/to/myapp`
+So, to see your app you'd run `devsrvr /path/to/my/app`, and visit `localhost:8000` in your browser.
+Each time you refresh the page, devsrvr will check whether your app needs to be rebuilt, and handle it if necessary. Any build errors are returned to you in the browser.
+### Options
+By default, devsrvr waits one second for your app to start up before proxying the first request, in order to catch any errors that occur on startup.
+You can adjust this startup timeout as well with the `startup` flag:
+    devsrvr -startup 0.5s /path/to/my/app
+## License
 devsrvr is available under the [Apache License, Version 2.0](