Giter Site home page Giter Site logo

devd's Introduction

Travis Build Status

devd: a local webserver for developers

screenshot

Install

Go to the releases page, download the package for your OS, and copy the binary to somewhere on your PATH.

If you have a working Go installation, you can also say

go get github.com/cortesi/devd/cmd/devd

Quick start

Serve the current directory, open it in the browser (-o), and livereload when files change (-l):

devd -ol .

Reverse proxy to http://localhost:8080, and livereload when any file in the src directory changes:

devd -w ./src http://localhost:8080

Using devd with modd

Modd is devd's sister project - a dev tool that runs commands and manages daemons in response to filesystem changes. Devd can be used with modd to rebuild a project and reload the browser when filesystem changes are detected.

Here's a quick example of a simple modd.conf file to illustrate.

src/** {
    prep: render ./src ./rendered
}

rendered/*.css ./rendered/*.html {
    daemon: devd -m ./rendered
}

The first block runs the render script whenever anything in the src directory changes. The second block starts a devd instance, and triggers livereload with a signal whenever a .css or .html file in the rendered directory changes.

See the modd project page for details.

Features

Cross-platform and self-contained

Devd is a single statically compiled binary with no external dependencies, and is released for macOS, Linux and Windows. Don't want to install Node or Python in that light-weight Docker instance you're hacking in? Just copy over the devd binary and be done with it.

Designed for the terminal

This means no config file, no daemonization, and logs that are designed to be read in the terminal by a developer. Logs are colorized and log entries span multiple lines. Devd's logs are detailed, warn about corner cases that other daemons ignore, and can optionally include things like detailed timing information and full headers.

Convenient

To make quickly firing up an instance as simple as possible, devd automatically chooses an open port to run on (unless it's specified), and can open a browser window pointing to the daemon root for you (the -o flag in the example above). It also has utility features like the -s flag, which auto-generates a self-signed certificate for devd, stores it in ~/.devd.certs and enables TLS all in one step.

Livereload

When livereload is enabled, devd injects a small script into HTML pages, just before the closing head tag. The script listens for change notifications over a websocket connection, and reloads resources as needed. No browser addon is required, and livereload works even for reverse proxied apps. If only changes to CSS files are seen, devd will only reload external CSS resources, otherwise a full page reload is done. This serves the current directory with livereload enabled:

devd -l .

You can also trigger livereload for files that are not being served, letting you reload reverse proxied applications when source files change. So, this command watches the src directory tree, and reverse proxies to a locally running application:

devd -w ./src http://localhost:8888

The -x flag excludes files from triggering livereload based on a pattern specification. The following command disables livereload for all files with the ".less" extension:

devd -x "**.less" -l .

When livereload is enabled (with the -L, -l or -w flags), devd responds to a SIGHUP by issuing a livereload notice to all connected browsers. This allows external tools, like devd's sister project modd, to trigger livereload. If livereload is not enabled, SIGHUP causes the daemon to exit.

The closing head tag must be found within the first 30kb of the remote file, otherwise livereload is disabled for the file.

Reverse proxy + static file server + flexible routing

Modern apps tend to be collections of web servers, and devd caters for this with flexible reverse proxying. You can use devd to overlay a set of services on a single domain, add livereload to services that don't natively support it, add throttling and latency simulation to existing services, and so forth.

Here's a more complicated example showing how all this ties together - it overlays two applications and a tree of static files. Livereload is enabled for the static files (-l) and also triggered whenever source files for reverse proxied apps change (-w):

devd -l \
-w ./src/ \
/=http://localhost:8888 \
/api/=http://localhost:8889 \
/static/=./assets

The route specification syntax is compact but powerful enough to cater for most use cases.

Light-weight virtual hosting

Devd uses a dedicated domain - devd.io - to do simple virtual hosting. This domain and all its subdomains resolve to 127.0.0.1, which we use to set up virtual hosting without any changes to /etc/hosts or other local configuration. Route specifications that don't start with a leading / are taken to be subdomains of devd.io. So, the following command serves a static site from devd.io, and reverse proxies a locally running app on api.devd.io:

devd ./static api=http://localhost:8888

Latency and bandwidth simulation

Want to know what it's like to use your fancy 5mb HTML5 app from a mobile phone in Botswana? Look up the bandwidth and latency here, and invoke devd like so (making sure to convert from kilobits per second to kilobytes per second and account for the location of your server):

devd -d 114 -u 51 -n 275 .

Devd tries to be reasonably accurate in simulating bandwidth and latency - it uses a token bucket implementation for throttling, properly handles concurrent requests, and chunks traffic up so data flow is smooth.

Routes

The devd command takes one or more route specifications as arguments. Routes have the basic format root=endpoint. Roots can be fixed, like "/favicon.ico", or subtrees, like "/images/" (note the trailing slash). Endpoints can be filesystem paths or URLs to upstream HTTP servers.

Here's a route that serves the directory ./static under /assets on the server:

/assets/=./static

To use a devd.io subdomain (which will resolve to 127.0.0.1), just add it to the the front of the root specification. We recognize subdomains by the fact that they don't start with a leading /. So, this route serves the /static directory under static.devd.io/assets:

static/assets=./static

Reverse proxy specifications are similar, but the endpoint specification is a URL. The following serves a local URL from the root app.devd.io/login:

app/login=http://localhost:8888

If the root specification is omitted, it is assumed to be "/", i.e. a pattern matching all paths. So, a simple directory specification serves the directory tree directly under devd.io:

devd ./static

Similarly, a simple reverse proxy can be started like this:

devd http://localhost:8888

There is also a shortcut for reverse proxying to localhost:

devd :8888

Serving default content for files not found

The --notfound flag can be passed multiple times, and specifies a set of routes that are consulted when a requested file is not found by the static file server. The basic syntax is root=path, where root has the same semantics as route specification. As with routes, the root= component is optional, and if absent is taken to be equal to /. The path is always relative to the static directory being served. When it starts with a leading slash (/), devd will only look for a replacement file in a single location relative to the root of the tree. Otherwise, it will search for a matching file by joining the specified path with all path components up to the root of the tree.

Let's illustrate this with an example. Say we have a /static directory as follows:

./static
├── bar
│   └── index.html
└── index.html

We can specify that devd should look for an index.html anywhere on the path to the root of the static tree as follows:

devd --notfound index.html  /static

Now, the following happens:

  • A request for /nonexistent.html returns the contents of /index.html
  • A request for /bar/nonexistent.html returns the contents of /bar/index.html
  • A request for /foo/bar/voing/index.html returns the contents of /index.html

We could instead specify an absolute path in the route, in which case the contents of /index.html would be returned for all the examples above:

devd --notfound /index.html  /static

Devd won't serve an over-ride page if the expected type of the incoming request doesn't match that of the override specification. We do this by looking at the file extension and expected MIME types of the over-ride and request, defaulting to text/html if the type couldn't be positively established. This prevents issues where, for instance, an HTML over-ride page might be served where images are expected.

Excluding files from livereload

The -x flag supports the following terms:

Term Meaning
* matches any sequence of non-path-separators
** matches any sequence of characters, including path separators
? matches any single non-path-separator character
[class] matches any single non-path-separator character against a class of characters
{alt1,...} matches a sequence of characters if one of the comma-separated alternatives matches

Any character with a special meaning can be escaped with a backslash (\). Character classes support the following:

Class Meaning
[abc] matches any single character within the set
[a-z] matches any single character in the range
[^class] matches any single character which does not match the class

About reverse proxying

Devd does not validate upstream SSL certificates when reverse proxying. For our use case, development servers will usually be running locally, often with self-signed certificates for testing. You shouldn't use devd in cases where upstream cert validation matters.

The X-Forwarded-Host and X-Forwarded-Proto headers are set to the devd server's address and protocol for reverse proxied traffic. You might need to enable support for this in your application for redirects and the like to work correctly.

Development

The scripts used to build this package for distribution can be found here. External packages are vendored using dep.

devd's People

Contributors

aellerton avatar brennie avatar chrissexton avatar cortesi avatar eticzon avatar giodamelio avatar homburg avatar jdknezek avatar judsonmitchell avatar kad avatar llimllib avatar mildred avatar schnouki avatar spytheman avatar wader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devd's Issues

not reloading

I'm trying to use devd to reload the page of a Django project, but it's not working. When I view the source I don't see the livereload JS being injected there. Am I doing something wrong? Here's my modd.conf:

/src/common/js/* {

    daemon: python manage.py runserver 0.0.0.0:8080
    daemon: ./devd --modd --address="0.0.0.0" --port=8000 http://localhost:8080

}

PHP processing?

Hi,
kudos on the work - tried with index.php but doesn't seem to recognise it? Anything I'm missing?
Thx, J

ARM Build

This looks like a great project. Any chance your can release a build for ARM machines? I'm hesitant to try compiling it myself....

point -h to --help flag

would be useful to point -h to --help

./devd.exe -h
devd.exe: error: unknown short flag '-h', try --help

Improperly serving 304 not modified

Here's a shell transcript where I quit devd, change directories, restart it, and it sends an improper 304:

#1. Serve from 576412
~/adhoc/homework/responses/576412/hhbuilder $ devd -ol .
23:26:51: Listening on http://devd.io:8000 (127.0.0.1:8000)
23:26:51: GET /
        <- 200 OK 4.4 kB
^C

#2. Switch to 265331
~/adhoc/homework/responses/576412/hhbuilder $ cd ../../265331/hhbuilder

#4. Serve from 265331: it serves a 304 instead of the new file
~/adhoc/homework/responses/265331/hhbuilder $ devd -ol .
13:24:13: Listening on http://devd.io:8000 (127.0.0.1:8000)
13:24:13: GET /
        <- 304 Not Modified
^C

#5. Show that the two files are different
01:24 PM nikkisix.local:~/adhoc/homework/responses/265331/hhbuilder  master
$ md5 index.html ../../576412/hhbuilder/index.html
MD5 (index.html) = dd2485ba30a7a2ac780b5fb297304a62
MD5 (../../576412/hhbuilder/index.html) = 23a8d6e84eecfc5b6645a471cc58101c

This is inside tmux on mac os x 10.11.4, though I have no idea if either of those matter!

This actually persists across my closing the terminal, opening a new one, and serving from that directory.

Unfortunately serving with --debug does not give any extra info:

$ devd -ol --debug .
13:35:29: Listening on http://devd.io:8000 (127.0.0.1:8000)
13:35:32: GET /
    debug fileserver: serving with FileServer...
    <- 304 Not Modified

One thing occurred to me, I moved directory 576412 while devd was serving from it; could that have been part of the cause?

Add default favicon.ico

Just like there is a default 404.html and dirlist.html, I think it would be beneficial to serve a default favicon.ico for when users are using the site to serve simple files. If nothing else, it helps keep logs clean of 404s.

I think it could be easily implemented in server.go:HandleNotFound and I am happy to submit a PR with what I can come up with, but I wanted to hear thoughts first.

Feature request: serve https

It would be good to be able to serve an app with a self-signed SSL certificate, to make sure that it's not throwing mixed content warnings etc before pushing it out.

@cortesi You're much more expert on the topic than I am; is this a plausible feature?

Integrated self-test ?

I'm planning to create formula for homebrew for devd. For that, it would be good if devd can be tested somehow. Currently it's not easily possible.
Maybe it's can be added functionality that would perform HEAD request to itself and validate some headers and exit with result code ?
Or something a bit more complex: start with directory parameter in test mode, try to request some file and validate it by also reading from filesystem ?

Or maybe something else in your opinion can be used as simple test of devd ?

Possible reverse proxy bug?

When I serve my site like this (minimized from the real example):

devd /veterans-employment-center/=http://localhost:8888/veterans-employment-center

The reverse proxy asks for the correct URL, http://localhost:8888/veterans-employment-center/:

$ ./serve.sh
10:31:02: Listening on http://devd.io:8000 (127.0.0.1:8000)
10:31:03: GET http://localhost:8888/veterans-employment-center/
  <- 404 Not Found 39B

But says it can't find it. That URL is valid and works:

$ curl http://localhost:8888/veterans-employment-center/
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

Is this a bug or am I doing something wrong?

Support range headers

Range headers allow the browser to only receive some part of a file.

Useful if you want to serve videos while developing with devd, especially DASH videos: I tried to use shaka player with devd, but it needs range headers when downloading parts of the mp4 files, otherwise it throws an error.

devd -l doesn't pick up changes to subfolders on OS X

sometime between v0.3 and v0.4 (i believe), devd -l stopped picking up changes to subdirectories on my system, only responding to changes in the folder specified. to demonstrate:

> devd -ol . &
> echo "hello" >> foo/bar # does not reload
> echo "world" >> baz     # reloads

however, given the following modd.conf, both changes are responded to:

** {
    daemon: devd -m .
}

system info:
OS X 10.11.3
go 1.6 installed via homebrew
devd installed via go get
modd installed via go get

Extend listener to use random port and choose interface to listen on

Hi there,

what do you think abou this:

Extend your listener logic to ask the user on which interface it should listen on using a random port to prevent any collisions. Maybe you could also present the user a list of available interfaces, she/he can choose from.

Something like https://github.com/fedux-org/local_webserver does. Feel free to copy over bits - MIT licensed. I wrote that web server to serve middleman-presentation-presentations which are build up on reveal.js (https://github.com/hakimel/reveal.js/)

Does websocket protocol work?

Hi,

Love devd!

I'm having trouble reverse proxying the ws protocol. The following runs:

devd -H /api/=http://localhost:8080/api /ws/=http://localhost:8080/ws public/

... but attempts to access the websocket (which work without devd) fail with:

WebSocket connection to 'ws://localhost:8000/ws' failed: Error during WebSocket handshake: Unexpected response code: 301

Thanks!
A

Pardon me - need build instructions

I am trying to build from the checked out code. I am not familiar with go package management.

amitava:devd amitava$ godep save -r
godep: cannot find package "github.com/cortesi/devd/inject" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/inject (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/inject (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/ricetemp" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/ricetemp (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/ricetemp (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/termlog" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/termlog (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/termlog (from $GOPATH)
godep: cannot find package "_/Users/amitava/opt/devd" in any of:
    /usr/local/opt/go/libexec/src/_/Users/amitava/opt/devd (from $GOROOT)
    /Users/amitava/golang/src/_/Users/amitava/opt/devd (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/fileserver" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/fileserver (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/fileserver (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/httpctx" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/httpctx (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/httpctx (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/inject" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/inject (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/inject (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/livereload" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/livereload (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/livereload (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/reverseproxy" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/reverseproxy (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/reverseproxy (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/ricetemp" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/ricetemp (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/ricetemp (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/slowdown" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/slowdown (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/slowdown (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/termlog" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/termlog (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/termlog (from $GOPATH)
godep: cannot find package "github.com/cortesi/devd/timer" in any of:
    /usr/local/opt/go/libexec/src/github.com/cortesi/devd/timer (from $GOROOT)
    /Users/amitava/golang/src/github.com/cortesi/devd/timer (from $GOPATH)
godep: cannot find package "github.com/dustin/go-humanize" in any of:
    /usr/local/opt/go/libexec/src/github.com/dustin/go-humanize (from $GOROOT)
    /Users/amitava/golang/src/github.com/dustin/go-humanize (from $GOPATH)
godep: cannot find package "github.com/fatih/color" in any of:
    /usr/local/opt/go/libexec/src/github.com/fatih/color (from $GOROOT)
    /Users/amitava/golang/src/github.com/fatih/color (from $GOPATH)
godep: cannot find package "github.com/rjeczalik/notify" in any of:
    /usr/local/opt/go/libexec/src/github.com/rjeczalik/notify (from $GOROOT)
    /Users/amitava/golang/src/github.com/rjeczalik/notify (from $GOPATH)
godep: cannot find package "github.com/toqueteos/webbrowser" in any of:
    /usr/local/opt/go/libexec/src/github.com/toqueteos/webbrowser (from $GOROOT)
    /Users/amitava/golang/src/github.com/toqueteos/webbrowser (from $GOPATH)
godep: cannot find package "golang.org/x/net/context" in any of:
    /usr/local/opt/go/libexec/src/golang.org/x/net/context (from $GOROOT)
    /Users/amitava/golang/src/golang.org/x/net/context (from $GOPATH)
godep: cannot find package "gopkg.in/alecthomas/kingpin.v2" in any of:
    /usr/local/opt/go/libexec/src/gopkg.in/alecthomas/kingpin.v2 (from $GOROOT)
    /Users/amitava/golang/src/gopkg.in/alecthomas/kingpin.v2 (from $GOPATH)
godep: error loading dependencies
amitava:devd amitava$

Is their a tool to download all the dependencies or do I need to individual run go get on each package?

panic: runtime error: cgo argument has Go pointer to Go pointer

I'm running on go 1.7.1, and when I try to run devd with livereload, I get this error.

# rahul @ cds-rahulretina in ~/Documents/ad [9:41:07] C:2
$ go version
go version go1.7.1 darwin/amd64

# rahul @ cds-rahulretina in ~/Documents/ad [9:41:10] 
$ devd -ol .
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
panic(0x440e9e0, 0xc420594020)
    /usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:500 +0x1a1
github.com/rjeczalik/notify.(*stream).Start(0xc4204d7a80, 0xc4204d7a80, 0xc42057e3f0)
    /Users/rahul/go/src/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:131 +0x1e4
github.com/rjeczalik/notify.(*fsevents).watch(0xc420509f20, 0xc420501e80, 0x19, 0x100001b00, 0x440bd00, 0xc42057e3c0)
    /Users/rahul/go/src/github.com/rjeczalik/notify/watcher_fsevents.go:206 +0x299
github.com/rjeczalik/notify.(*fsevents).RecursiveWatch(0xc420509f20, 0xc420501e80, 0x19, 0x1b0000001b00, 0x0, 0xc4204cf860)
    /Users/rahul/go/src/github.com/rjeczalik/notify/watcher_fsevents.go:258 +0x4f
go.(*struct { github.com/rjeczalik/notify.watcher; github.com/rjeczalik/notify.recursiveWatcher }).RecursiveWatch(0xc420501620, 0xc420501e80, 0x19, 0xc400001b00, 0xc4204cf860, 0x201b00)
    <autogenerated>:50 +0x66
github.com/rjeczalik/notify.(*recursiveTree).Watch(0xc42050c370, 0xc420501e80, 0x19, 0xc4204cf860, 0xc42055a7e4, 0x1, 0x1, 0x0, 0x0)
    /Users/rahul/go/src/github.com/rjeczalik/notify/tree_recursive.go:286 +0xe5d
github.com/rjeczalik/notify.Watch(0xc42055a7e0, 0x3, 0xc4204cf860, 0xc42055a7e4, 0x1, 0x1, 0x46aa500, 0xc4204cf800)
    /Users/rahul/go/src/github.com/rjeczalik/notify/notify.go:64 +0x78
github.com/cortesi/modd.Watch(0xc42055a7c0, 0x1, 0x1, 0x0, 0x0, 0x0, 0xbebc200, 0xc4204cf800, 0x400f2f1, 0xc42057d550)
    /Users/rahul/go/src/github.com/cortesi/modd/modd.go:286 +0x147
github.com/cortesi/devd.Route.Watch(0x0, 0x0, 0x44866c6, 0x1, 0x467c7a0, 0xc42055a590, 0xc4204cf7a0, 0x0, 0x0, 0x0, ...)
    /Users/rahul/go/src/github.com/cortesi/devd/watch.go:19 +0x143
github.com/cortesi/devd.WatchRoutes(0xc4205075c0, 0x467c820, 0xc4204d7a00, 0x0, 0x0, 0x0, 0x4682c00, 0xc420501c80, 0xc4204d79c0, 0x46aa500)
    /Users/rahul/go/src/github.com/cortesi/devd/watch.go:55 +0x168
github.com/cortesi/devd.(*Devd).Router(0xc42008d780, 0x4682c00, 0xc420501c80, 0xc420507740, 0x200000003, 0xc420020a00, 0xc4200001a0, 0xc420057868)
    /Users/rahul/go/src/github.com/cortesi/devd/server.go:255 +0x6e4
github.com/cortesi/devd.(*Devd).Serve(0xc42008d780, 0x448b0f9, 0x9, 0x0, 0x0, 0x0, 0x4682c00, 0xc420501c80, 0xc42057dcf0, 0x28, ...)
    /Users/rahul/go/src/github.com/cortesi/devd/server.go:289 +0x156
main.main()
    /Users/rahul/go/src/github.com/cortesi/devd/cmd/devd/devd.go:214 +0x2766

Is there a compatibility restriction?

Any option for gzip compression?

Hi Cortesi,
This is an awesome project! Totally prefer to use this then SimpleHTTPServer. However, I saw on a review site, which led me here, that they had a screenshot where it showed gzip compression. Is there a switch or config file change that I am missing or does that not exist in DevD? If not, then are there plans to include this feature in a future release? I also searched for plugins but couldn't find anything in a quick Google search. If you could provide an option for gzip, it would be greatly appreciated!
Thanks!

quiet mode

It would be nice to have a quiet mode which does not log anything to the console.

CORS support

Since devd allows subdomains in some super-simple way. It would be nice to support CORS too. I believe that something like --allow-cors that allows every header and every method on * or *.devd.io (not sure what the best option is) would be good enough for development.

modd escaping values in terminal (configuration struct)

Hello!

I have a JSON that is shown in the terminal with MarshalIndent and it's not looking good with modd, because of escaping. It's shown because its application configuration, for instance:

{\n\t\t\"Host\": \"http://localhost:8086\",\n\t\t\"Username\": \"user\",\n\t\t\"Password\": \"user\",\n\t\t\"BatchSize\": 1000\n\t}\n}"

I looked at the cli --help and I did not find any solution: Is there any way to disable escaping nowadays?

Thanks!

Proxying of https sites with SNI does not work

When trying to proxy our https-site (let's call it xyz.abc) through devd, I get 400 ("Bad Request") errors. The apache logs say: "Hostname xyz.abc provided via SNI and hostname devd.io provided via HTTP are different".

I am not entirely sure how SNI works but it seems that the hostname entered into the browser is transmitted to the webserver. Devd should rewrite this so that it matches the hostname of the proxied webserver.

Add option to not rewrite Host header in reverse-proxy

See #56 for the context. My downstream server doesn't look at X-Forwarded-Host, expecting the Host header to be the original one received by the reverse proxy (HAProxy in our case in production).

I understand that others proxying to a live server with virtual hosts won't want that behavior, so it should be an option, and preferably per-route.

Maybe add a notation like prefixing a URL with + (or another character) will preserve the req.Host instead of rewriting it to target.Host?

Pass X-Forwarded-Proto in addition to X-Forwarded-Host in reverse-proxy mode

I have an application whose behavior changes (generates https:// vs. http:// URLs, set Secure flag on cookies) depending on whether it runs behind a TLS-terminating reverse proxy (production, HAProxy) or not (local dev, plain HTTP). This is done switching on a X-Forwarded-Proto request header (if set to https, we're behind the reverse proxy, otherwise –not set, or other value– we're not).

I'd like to easily test it locally using HTTPS, from time to time, to verify the expected in-production logic.

Looking around for a simple reverse-proxy with TLS support for development, I found devd, but it doesn't add X-Forwarded-Proto.

Live reload over ssl in Chrome fails when Chrome blocks attempt to load .devd.livereload over insecure Websocket endpoint ws

I'm getting this on Chrome Win 7 64.

Mixed Content: The page at 'https://devd.io/jQuerUIfy/README.html' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://devd.io/.devd.livereload'. This request has been blocked; this endpoint must be available over WSS.ReconnectingWebSocket.open @ .devd.livereload.js:118ReconnectingWebSocket @ .devd.livereload.js:203(anonymous function) @ .devd.livereload.js:278(anonymous function) @ .devd.livereload.js:302
.devd.livereload.js:118 Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.ReconnectingWebSocket.open @ .devd.livereload.js:118ReconnectingWebSocket @ .devd.livereload.js:203(anonymous function) @ .devd.livereload.js:278(anonymous function) @ .devd.livereload.js:302

32-bit Windows support

Does devd support 32-bit Windows 8?
I'm running devd and getting following error on git bash:
bash: /c/Windows/system32/devd: cannot execute binary file: Exec format error
Also, cmd.exe even doesn't see the executable.
I was using devd-0.4-windows64.zip. And devd-0.4-linux64.tgz for git bash additionaly.

panic running under OSX Sierrra

devd version: 0.5
Runs for a while, then I get

unexpected fault address 0x8c0debfff95
fatal error: fault
[signal 0xb code=0x1 addr=0x8c0debfff95 pc=0x8c0debfff95]

goroutine 50 [running]:
runtime.throw(0x46322c8, 0x5)
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:530 +0x90 fp=0xc8204f1830 sp=0xc8204f1818
runtime.sigpanic()
/usr/local/Cellar/go/1.6/libexec/src/runtime/sigpanic_unix.go:27 +0x2ba fp=0xc8204f1880 sp=0xc8204f1830
github.com/cortesi/termlog.(_Log).format(0xc8205d0e40, 0x4e67201, 0x0, 0x462d2d0, 0x2, 0xc820532f20, 0x1, 0x1, 0x0, 0x0)
/Users/cortesi/mygo/src/github.com/cortesi/termlog/termlog.go:134 +0x1bb fp=0xc8204f1938 sp=0xc8204f1880
github.com/cortesi/termlog.(_Log).SayAs(0xc8205d0e40, 0x4631ac0, 0x5, 0x462d2d0, 0x2, 0xc820532f20, 0x1, 0x1)
/Users/cortesi/mygo/src/github.com/cortesi/termlog/termlog.go:215 +0x7f fp=0xc8204f19e0 sp=0xc8204f1938
github.com/cortesi/modd/watch.batch(0xbebc200, 0x1dcd65000, 0x4ec5340, 0x492b800, 0xc8205a85a0, 0x4ec5340)
/Users/cortesi/mygo/src/github.com/cortesi/modd/watch/watch.go:255 +0x449 fp=0xc8204f1ea0 sp=0xc8204f19e0
github.com/cortesi/modd/watch.Watch.func1(0xbebc200, 0xc8205a85a0, 0xc82065c760, 0x1, 0x1, 0xc8205a8540)
/Users/cortesi/mygo/src/github.com/cortesi/modd/watch/watch.go:309 +0xa1 fp=0xc8204f1f70 sp=0xc8204f1ea0
runtime.goexit()
/usr/local/Cellar/go/1.6/libexec/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc8204f1f78 sp=0xc8204f1f70
created by github.com/cortesi/modd/watch.Watch
/Users/cortesi/mygo/src/github.com/cortesi/modd/watch/watch.go:318 +0x223

CGI support?

Hi,

Any chance of adding CGI support (yes I know it's not 1997 anymore)?

For example something like this, where '%' instead of '=' denotes the cgi path, or something like that...

devd /=./pathtohtml /cgi-bin%./pathtocgidir 

Thanks
Matt

devd -ol . returns error on Windows 7

I try to start devd following the example in the documentation but it always returns an error:

devd is in c:\tools and my files are in a different folder e.g. c:\projects\test

c:\tools\devd -ol .

returns the following error:

devd :error : could not watch routes for livereload: the syntax of the filename, foldername of volumename is incorrect

I am using version 0.2 (on windows 7 64bit)
When I specify the full pathname of the folder, it works.

c:\tools\devd -ol c:\projects\test

Ability to specify 404 page/handler

For better or worse, I'm using react-router with browserHistory on a project which turns hash routes (devd.io/#/foo) into prettier urls (devd.io/foo). This functionality requires specific setup in the server software and I do not believe it is currently possible to configure devd to support this.

The recommended setup for nginx is to use the try_files directive to fall back on your react entry page if the file is not found (try_files $uri /index.html). I believe the simplest way to support this functionality in devd would be to allow for a 404 handler or fallback to be specified when the file server cannot find the specified resource. Perhaps a more robust way would be an extension to the routing syntax to allow for greater flexibility.

Thank you for your consideration

File level routes not working, redirect to '/'

Unfortunately, the server that I'm trying to mock maps '/' in paths in the source code to '.' in the URL, which means that I have to resort to file-level routing for the files that I'm developing.

I specify a file-level routes that fall back to the original server like this:

devd -p 9443 -s /=https://localhost:9444/ /ctx/app.foo.bar.bundle.ui.internal.view.baz.MyModule.js=/Users/cmcgee/Documents/workspace4/app.foo.bar.bundle.ui/resources/internal/view/baz/MyModule.js

However, when I GET /ctx/app.foo.bar.bundle.ui.internal.view.baz.MyModule.js it gets redirected with 301 to /

In my version of devd I hacked fileserver/fileserver.go to work around the problem:
diff --git a/fileserver/fileserver.go b/fileserver/fileserver.go
index b1a88d6..06af8ba 100644
--- a/fileserver/fileserver.go
+++ b/fileserver/fileserver.go
@@ -219,7 +219,7 @@ func (fserver *FileServer) ServeHTTPContext(
upath = "/" + upath
r.URL.Path = upath
}

  • fserver.serveFile(logger, w, r, path.Clean(upath), true)
  • fserver.serveFile(logger, w, r, path.Clean(upath), false)
    }

Clearly, this is just a hack and I don't know all of the implications of this change. Perhaps, there is even a better way to do the more complex mapping that I need?

Port number is missing from HTTP_HOST

Hello,

devd is really a great idea, something I already searched for some time now.

But when I tried it out on my development system, I had the issue, that the original port number used is not reflected in the HTTP_HOST. I understand, that there where an issue with a different customer, that had problems when the port number is not stripped. But wouldn't it make sense to provide an option for that behavior because at least in my setting, I want to redirect to a different page of my own web-site and the Django framework does create the URL from the HTTP_HOST -- which will be wrong without port number.

Edit:
I would do the change myself and fork the project, but currently I am not working with go, so it would be a big overhead for me. Also I think, that such a switch would be beneficial also for other people using Django or similar frameworks.

Best Regards and thank you for that great tool!

/juergen

Error with devd ssl

I'm trying out the new flag and serving my site with: devd -s ., but Chrome just downloads a gibberish file. Console says:

Resource interpreted as Document but transferred with MIME type application/octet-stream: "http://devd.io:8000/".

Serving without -s works fine; serving with -c and a cert generated with the command you gave in this issue fails in the same way.

Firefox serves a page, but just shows a few error characters. Safari says "Safari can't open the page".

go get fails

Hey,

i tried to install this via go get github.com/cortesi/devd, but this fails -

% go get github.com/cortesi/devd
# github.com/cortesi/devd/termlog
src/go/src/github.com/cortesi/devd/termlog/termlog.go:153: undefined: color.NoColor

being newish to go, not sure if i've invoked something wrong here by deviating from your build steps... so would appreciate any insight. :)

looks like a great little project.

one-line log output

Hello,

devd looks really great, so far, but I was wondering if it was possible to add an option to enable one-line log output. My use-cases:

What if I want to grep devd command line output to look after:

  • the 404 or the 500 errors
  • which .css files are loaded and see their different HTTP status

by just adding a "--one-line" option, one could filter out unwanted lines.

does not serve static directory correctly on windows

I tried running devd purely to serve files in a directory under http://devd.io/static/, but could not get it to work. Looks like a bug to me.

Running devd 7bc137d on windows8, go1.5.1, 64-bit, git bash.

mkdir tmp
echo hello > tmp/hello.txt
bin/devd -p 8000 /static/=./tmp/

Then

curl http://devd.io:8000/static/hello.txt

Expected: prints hello.
Actual: 404 File not found
Curiously it also does not log the 404.

It works on linux and logs a 404 if I request something that is not there.

Support build commands

It would be awesome if devd could be responsible for building as well as live reload. Essentially I would love to specify a pattern to watch and a command to execute if one of those files changed. I imagine the API could look something like:

devd --livereload --watch ./build --srcs ./src --exec "make"

I'm not sure what the exec and exec watch path would be.

Strange console logging of encoded chars

Encoded query params gets logged somewhat weird:

$> devd --version
0.4
$> devd . &
curl -s devd.io:8000/foo?bar=%3A%2F%2F  > /dev/null

produces the following log line

10:53:54: GET /foo?bar=%!A(MISSING)%!F(MISSING)%!F(MISSING)

Shouldn't it just write the path and params without parsing ?

Add exclude/ignore filters for watched directory

Ignore filters would be very handy when other programs edit files in the watched directory. Eg

  • In Typescript you save a .ts file, then the compiler generates a .js file. This causes 2 reloads
  • TourtiseHG makes a temporary hg-checkexec file both periodically and after refresh, which causes the page to reload

In cases like this some kind of --exclude="hg-checkexec_" --exclude="_.ts" switch would be useful.

LiveReload doesn't happen on Firefox

... and instead logs this error message in the console:

The connection to ws://devd.io:8000/.devd.livereload was interrupted while the page was loading.

I did start a simple devd -ol ., using devd 0.2, from a folder hosting some static pages, and modified the css background to red. Expected result: background turns red. Actual: nothing, except the error message in the log.

May be related to this stackoverflow post and bugzilla#712329?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.