Compare commits

..

7 Commits

Author SHA1 Message Date
Adnan Hajdarević 7b8cc04992 Merge pull request #38 from adnanh/development
Fail if webhook cannot load hooks when not running in verbose mode (unless -nopanic flag is used)
2015-10-04 17:08:51 +02:00
Adnan Hajdarevic d4810bebdb Merge branch 'master' into development 2015-10-04 17:06:34 +02:00
Adnan Hajdarevic 272546bb2b add nopanic flag 2015-10-04 17:06:17 +02:00
Adnan Hajdarević 2afc6e6a54 Merge pull request #35 from ciarand/patch-1
Fix reverse build tag in webhook_windows.go
2015-07-23 17:08:10 +02:00
Ciaran Downey a5c92b88a6 Fix reverse build tag in webhook_windows.go
9c545a745f accidentally started negating
the build constraint in webhook_windows.go. This reverses that, fixing
the Windows build.
2015-07-22 14:58:54 -07:00
Adnan Hajdarević d12bbf4036 Update README.md 2015-06-10 09:33:15 +02:00
Adnan Hajdarević d91b34a316 Update README.md 2015-06-10 09:32:07 +02:00
3 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
[![Join the chat at https://gitter.im/adnanh/webhook](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/adnanh/webhook?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/adnanh/webhook](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/adnanh/webhook?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Flattr this](https://button.flattr.com/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=adnanh&url=https%3A%2F%2Fwww.github.com%2Fadnanh%2Fwebhook)
# What is webhook? # What is webhook?
[webhook](https://github.com/adnanh/webhook/) is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands. You can also pass data from the HTTP request (such as headers, payload or query variables) to your commands. [webhook](https://github.com/adnanh/webhook/) also allows you to specify rules which have to be satisfied in order for the hook to be triggered. [webhook](https://github.com/adnanh/webhook/) is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands. You can also pass data from the HTTP request (such as headers, payload or query variables) to your commands. [webhook](https://github.com/adnanh/webhook/) also allows you to specify rules which have to be satisfied in order for the hook to be triggered.
+7 -1
View File
@@ -25,13 +25,14 @@ import (
) )
const ( const (
version = "2.3.4" version = "2.3.5"
) )
var ( var (
ip = flag.String("ip", "", "ip the webhook should serve hooks on") ip = flag.String("ip", "", "ip the webhook should serve hooks on")
port = flag.Int("port", 9000, "port the webhook should serve hooks on") port = flag.Int("port", 9000, "port the webhook should serve hooks on")
verbose = flag.Bool("verbose", false, "show verbose output") verbose = flag.Bool("verbose", false, "show verbose output")
noPanic = flag.Bool("nopanic", false, "do not panic if hooks cannot be loaded when webhook is not running in verbose mode")
hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically") hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically")
hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve") hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve")
hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)") hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)")
@@ -73,6 +74,11 @@ func init() {
err := hooks.LoadFromFile(*hooksFilePath) err := hooks.LoadFromFile(*hooksFilePath)
if err != nil { if err != nil {
if !*verbose && !*noPanic {
log.SetOutput(os.Stdout)
log.Fatalf("couldn't load any hooks from file! %+v\naborting webhook execution since the -verbose flag is set to false.\nIf, for some reason, you want webhook to start without the hooks, either use -verbose flag, or -nopanic", err)
}
log.Printf("couldn't load hooks from file! %+v\n", err) log.Printf("couldn't load hooks from file! %+v\n", err)
} else { } else {
log.Printf("loaded %d hook(s) from file\n", len(hooks)) log.Printf("loaded %d hook(s) from file\n", len(hooks))
+7 -3
View File
@@ -1,5 +1,3 @@
//+build !windows
package main package main
import ( import (
@@ -23,13 +21,14 @@ import (
) )
const ( const (
version = "2.3.4" version = "2.3.5"
) )
var ( var (
ip = flag.String("ip", "", "ip the webhook should serve hooks on") ip = flag.String("ip", "", "ip the webhook should serve hooks on")
port = flag.Int("port", 9000, "port the webhook should serve hooks on") port = flag.Int("port", 9000, "port the webhook should serve hooks on")
verbose = flag.Bool("verbose", false, "show verbose output") verbose = flag.Bool("verbose", false, "show verbose output")
noPanic = flag.Bool("nopanic", false, "do not panic if hooks cannot be loaded when webhook is not running in verbose mode")
hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically") hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically")
hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve") hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve")
hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)") hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)")
@@ -63,6 +62,11 @@ func init() {
err := hooks.LoadFromFile(*hooksFilePath) err := hooks.LoadFromFile(*hooksFilePath)
if err != nil { if err != nil {
if !*verbose && !*noPanic {
log.SetOutput(os.Stdout)
log.Fatalf("couldn't load any hooks from file! %+v\naborting webhook execution since the -verbose flag is set to false.\nIf, for some reason, you want webhook to start without the hooks, either use -verbose flag, or -nopanic", err)
}
log.Printf("couldn't load hooks from file! %+v\n", err) log.Printf("couldn't load hooks from file! %+v\n", err)
} else { } else {
log.Printf("loaded %d hook(s) from file\n", len(hooks)) log.Printf("loaded %d hook(s) from file\n", len(hooks))