Rodreegez/powder — pull request #53 by phil-monroe (2011-11-26 05:13:35+00:00)
Title: Powder Server

This adds a simple Sinatra web server in the `lib` directory that will mimic functionality of the CLI. Currently the only CLI functionality implemented is the restart action. This allows you to create a bookmark in your web browser that will restart your app and redirect you to the root url of that app.

### How to use

``` sh
gem install powder
cd to/app/path
powder link appname
powder server
```

Now if you visit `powder-server.dev/restart` the app that is linked to `appname.dev/` will be restarted and you will be redirected to the root url.

### Custom Redirect

If you don't want to redirect to the root url of your app, you can pass in the `redirect` HTTP param for the url you want to redirect to. For example `powder-server/restart?redirect=www.appname.dev` will restart your app and redirect you to the www subdomain for your app.

### Oddities

For some reason the powder-server throws an error on the first load after a fresh version of the gem is installed. Not sure what is causing it, but I added the ability to restart the powder-server and then it works just fine.

``` sh
powder server restart
```

### CLI Additions

`powder server` - Run in the directory of the app that you want the server to follow. This starts the server and tells the server which app to use.

`powder server restart` - Restarts the server. Use if the server isn't working properly.

`powder server down` - Kills the powder server.

### Future

I think it would be cool if you could control `always_restart` and `no_restarts` from the browser, but this could theoretically be used for any functionality that the CLI provides. I just thought I would throw this out there to see if anyone was interested.

If this does seem like a good idea, it would be nice to refactor some of the functionality of the CLI into a module that could be included by the CLI and server. This would help DRY up the code.

Let me know what you think!