Skip to content

Commit

Permalink
Listen on PORT if avaialable otherwise 3030
Browse files Browse the repository at this point in the history
  • Loading branch information
baldmountain committed Feb 8, 2017
1 parent b82c2e5 commit 4e2070b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 3.1.2 [2017-02-08]

* Listen on the port specified by the PORT environment variable. Otherwise use 3030.

### 3.1.1 [2016-10-07]

* Fix public route handling
Expand Down Expand Up @@ -106,4 +110,4 @@
* Add AnswerHub provider
* Add Github provider
* Add Slack provider
* Initial release
* Initial release
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ providers:
key: {{env "FERRET_TRELLO_KEY"}}
```
Set the environment variables base on `ferret.yml` and credentials.
Set the environment variables base on `ferret.yml` and credentials.

_Note: Environment directives (`{{env ...}}`) can be replaced with credentials.
But it's not recommended for production usage._
Expand All @@ -147,6 +147,7 @@ But it's not recommended for production usage._
### Build

```bash
go get github.com/rakyll/statik
go get -u -v github.com/yieldbot/ferret
cd $GOPATH/src/github.com/yieldbot/ferret
go generate ./assets
Expand Down Expand Up @@ -190,7 +191,7 @@ All contributions are welcome. However there are rules and guidelines;

### License

Licensed under The MIT License (MIT)
Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.


Expand Down
7 changes: 6 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"strings"

"github.com/yieldbot/ferret/assets"
Expand All @@ -22,6 +23,7 @@ import (
var (
config conf.Listen
providers []provider
port string
)

// httpError represents an HTTP error
Expand All @@ -41,7 +43,10 @@ type provider struct {
// Init initializes the api
func Init(c conf.Config) {
config = c.Listen

port = os.Getenv("PORT")
if port != "" {
config.Address = ":" + port
}
if config.Address == "" {
config.Address = ":3030"
}
Expand Down

0 comments on commit 4e2070b

Please sign in to comment.