Skip to content

Commit

Permalink
chore: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
PatKoperwas committed Mar 1, 2018
1 parent 9e90d4c commit 6a51a75
Showing 1 changed file with 12 additions and 51 deletions.
63 changes: 12 additions & 51 deletions README.md
Expand Up @@ -5,8 +5,8 @@ Tychus is a command line utility for live reloading applications. Tychus serves
your application through a proxy. Anytime the proxy receives an HTTP request, it
will automatically rerun your command if the filesystem has changed.

`tychus` is language agnostic - it can be configured to work with just about
anything: Go, Rust, Ruby, Python, scripts & arbitrary commands.
`tychus` is language agnostic - it can be configured to work with anything: Go,
Rust, Ruby, Python, scripts, and arbitrary commands.


## Installation
Expand All @@ -30,22 +30,21 @@ Currently isn't supported :(

## Usage

Usage is simple, `tychus` and then your command. That will start a proxy on port
`4000`. When an HTTP request comes in and the filesystem has changed, your
command will be rerun.
Usage is simple, `tychus [command]` A proxy will be started on port `4000`. When
an HTTP request comes in and the filesystem has changed, your command will be
rerun.

```
tychus go run main.go
```

## Options
Tychus has a few options. In most cases the defaults should be sufficient. See
below for a few examples.
Tychus has a few options. In most cases the defaults should be sufficient.

```yaml
-a, --app-port int port your application runs on, overwritten by ENV['PORT'] (default 3000)
-p, --proxy-port int proxy port (default 4000)
-x, --ignore stringSlice comma separated list of directories to ignore file changes in. (default [node_modules,log,tmp,vendor])
-x, --ignore stringSlice comma separated list of directories to ignore file changes in. (default node_modules,log,tmp,vendor)
--wait Wait for command to finish before proxying a request.
-t, --timeout int timeout for proxied requests (default 10)

Expand All @@ -55,7 +54,7 @@ below for a few examples.
--version version for tychus
```

Note: Tychus will not look for file system changes any hidden directories
Note: Tychus will not look for file system changes in any hidden directories
(those beginning with `.`).

## Examples
Expand Down Expand Up @@ -115,51 +114,13 @@ tychus "multimarkdown docs/index.md > public/index.html" --wait --app-port=3005

Now, when you make a request to the proxy on `localhost:4000`, `tychus` will
pause the request (that's what the `--wait` flag is for) until `multimarkdown`
finishes. Then it will forward the request to the server on port `3005`.
finishes. Then request will be forwarded to the server on port `3005`.
`multimarkdown` will only be run if the filesystem has changed.


**Advanced Example: Reload Scripts and Webserver**

Like the scenario above, but you also want your server to autoreload as files
change. You can chain `tychus` together, by setting the `app-port` equal to the
`proxy-port` of the previous `tychus`. An example:

The first instance of `tychus` will run a Go webserver that serves assets out of
`public/`. We only want it to restart when the `app` folder changes, so ignore
`docs` and `public` directories.

```
$ tychus go run main.go --app-port=3000 --proxy-port=4000 --ignore=docs,public
[tychus] Proxing requests on port 4000 to 3000
...
...
```

In order to serve upto date docs, `multimarkdown` needs to be invoked to
transform markdown into servable html. So we start another `tychus` process to
and point its app-port to server's proxy port.

```
$ tychus "multimarkdown docs/index.md > public/index.html" --wait --app-port=4000 --proxy-port=4001
```

Now, there is a proxy running on `4001` pointing at a proxy on `4000` pointing
at a webserver on `3000`. If you save `docs/index.html`, and then make a request
to `localhost:4001`, that will pause the request while `multimarkdown` runs.
Once it is finished, the requests gets forwarded to `localhost:4000`, which in
turn forwards it our websever on `3000`. The request gets sent all the way back,
with the correctly updated html!

Had our server code been modified in the `app/` folder, then after
`multimarkdown` finished, and the request got passed on to `4000`, that would
have also triggered a restart of our websever.

**Other Proxy Goodies**

**Error messages**

If you make a syntax error, or your program won't build for some reason, stderr
will be returned by the proxy. Handy for the times you can't see you server (its
in another pane / tab / tmux split).
If you make a syntax error, or your program won't build for some reason, the
stderr output will be returned by the proxy. Handy for the times you can't see
you server (its in another pane / tab / tmux split).

0 comments on commit 6a51a75

Please sign in to comment.