chook 1.0.1.b2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +21 -0
- data/README.md +243 -36
- data/bin/chook-server +29 -1
- data/data/chook.conf.example +104 -0
- data/data/sample_handlers/RestAPIOperation.rb +12 -8
- data/data/sample_handlers/SmartGroupComputerMembershipChange.rb +3 -6
- data/data/sample_jsons/SmartGroupComputerMembershipChange.json +3 -1
- data/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +3 -1
- data/lib/chook/configuration.rb +20 -8
- data/lib/chook/event/handled_event.rb +15 -12
- data/lib/chook/event/handled_event/handlers.rb +136 -83
- data/lib/chook/event/handled_event_logger.rb +86 -0
- data/lib/chook/event_handling.rb +1 -0
- data/lib/chook/foundation.rb +2 -0
- data/lib/chook/procs.rb +17 -1
- data/lib/chook/server.rb +71 -74
- data/lib/chook/server/log.rb +215 -0
- data/lib/chook/server/public/css/chook.css +125 -0
- data/lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png +0 -0
- data/lib/chook/server/public/js/chook.js +127 -0
- data/lib/chook/server/public/js/logstream.js +101 -0
- data/lib/chook/server/routes.rb +45 -0
- data/lib/chook/server/routes/handle_webhook_event.rb +22 -3
- data/lib/chook/server/routes/handlers.rb +52 -0
- data/lib/chook/server/routes/home.rb +34 -1
- data/lib/chook/server/routes/log.rb +106 -0
- data/lib/chook/server/views/admin.haml +11 -0
- data/lib/chook/server/views/bak.haml +48 -0
- data/lib/chook/server/views/config.haml +15 -0
- data/lib/chook/server/views/handlers.haml +48 -0
- data/lib/chook/server/views/layout.haml +39 -0
- data/lib/chook/server/views/logstream.haml +32 -0
- data/lib/chook/server/views/sketch_admin +44 -0
- data/lib/chook/subject.rb +1 -2
- data/lib/chook/subject/smart_group.rb +6 -0
- data/lib/chook/version.rb +1 -1
- metadata +73 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 05defee2dbf9d0d71b7657d491ac8eebf3c87529d1de1077365a3a2e82cc48fe
|
4
|
+
data.tar.gz: 845d410b10290129a233915600cf57ca7c89a855b2d504cb5593da885e5eef8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 153586d027c5c81d7ec5d0f0678d0c520879db7cef84cf3454134a4f7439601faa12463a3d227e7dd1ce6b561c18d4c95be781f39b2d0d787be742d5ea0b44fa
|
7
|
+
data.tar.gz: 10e36a024704ab54f38bfbfeec7f91da08a294c9a3d0c1b3c103d0aa924719045197a4f62e49ef4e4add8397004fc8578186d3c50ec03d53501839ac716384a5
|
data/CHANGES.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Chook Change Log
|
2
|
+
|
3
|
+
## v 1.1.0, 2018-10-15
|
4
|
+
|
5
|
+
For details about the new features, please see README.md
|
6
|
+
|
7
|
+
- Now requires 'thin' as the server engine.
|
8
|
+
|
9
|
+
|
10
|
+
- Supports SSL and HTTP Basic Authentication
|
11
|
+
|
12
|
+
|
13
|
+
- Server logging is now a thing, with access to logging from both internal and external handlers
|
14
|
+
|
15
|
+
|
16
|
+
- A simple admin interface is available by pointing your browser at the chook server
|
17
|
+
|
18
|
+
|
19
|
+
- Internal handlers are now stored as anonymous objects rather than Procs, and the handler code block
|
20
|
+
is stored as an instance method on the object. This means that either 'break' or 'return' will work
|
21
|
+
to exit a handler.
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
|
2
2
|
# Chook
|
3
3
|
|
4
|
-
Documentation is a work in progress. Please get in touch for assistance. <3
|
4
|
+
Documentation is a work in progress. Please [get in touch](mailto:chook@pixar.com) for assistance. <3
|
5
5
|
|
6
6
|
- [Introduction](#introduction)
|
7
|
+
- [Installing Chook](#installing-chook)
|
7
8
|
- [The Framework](#the-framework)
|
8
9
|
- [Event Handlers](#event-handlers)
|
9
10
|
- [Internal Handlers](#internal-handlers)
|
@@ -11,7 +12,11 @@ Documentation is a work in progress. Please get in touch for assistance. <3
|
|
11
12
|
- [Putting It Together](#putting-it-together)
|
12
13
|
- [Events and Subjects](#events-and-subjects)
|
13
14
|
- [The Server](#the-server)
|
14
|
-
- [
|
15
|
+
- [Server Configuration](#server-configuration)
|
16
|
+
- [SSL](#ssl)
|
17
|
+
- [Logging](#logging)
|
18
|
+
- [Admin Interface](#admin-interface)
|
19
|
+
- [Pointing Jamf Pro at your Chook server](#pointing-jamf-pro-at-your-chook-server)
|
15
20
|
- [TODOs](#todos)
|
16
21
|
|
17
22
|
|
@@ -19,36 +24,46 @@ Documentation is a work in progress. Please get in touch for assistance. <3
|
|
19
24
|
|
20
25
|
Chook is a Ruby module that implements a framework for working with webhook events
|
21
26
|
sent by the JSS, the core of [Jamf Pro](https://www.jamf.com/products/jamf-pro/),
|
22
|
-
a management tool for Apple devices
|
27
|
+
a management tool for Apple devices!
|
23
28
|
|
24
29
|
Chook also provides a simple, sinatra-based HTTP server for handling those Events,
|
25
30
|
and classes for sending simulated TestEvents to a webhook handling server.
|
26
31
|
|
27
|
-
**
|
32
|
+
**You do not need to be a Ruby developer to use Chook!**
|
28
33
|
|
29
34
|
The webhook handling server that comes with Chook can use "Event Handlers" written in
|
30
35
|
any language. See _Event Handlers_ and _The Server_ below for more information.
|
31
36
|
|
32
|
-
Chook is still in development. While many of the basics work,
|
33
|
-
there is much to be done before it can be considered complete.
|
34
|
-
|
35
37
|
Although Chook integrates well with [ruby-jss](http://pixaranimationstudios.github.io/ruby-jss/index.html),
|
36
38
|
it's a separate tool, and the two projects aren't dependent. However, ruby-jss
|
37
39
|
does become a requirement when using sampling features to generate TestEvents.
|
38
40
|
|
39
41
|
For more detail about the JSS webhooks API and the JSON data it passes, please see
|
40
|
-
[
|
42
|
+
[JAMF's developer reference.](http://developer.jamf.com/webhooks)
|
41
43
|
|
42
44
|
**Note:** When creating webhooks from your JSS to be handled by the framework, you must
|
43
45
|
specify JSON in the "Content Type" section. This framework does not support XML and
|
44
|
-
will only generate Events in JSON format.
|
46
|
+
will only generate Test Events in JSON format.
|
47
|
+
|
48
|
+
|
49
|
+
## Installing Chook
|
50
|
+
|
51
|
+
`gem install chook -n /usr/local/bin`
|
52
|
+
|
53
|
+
It will also install "sinatra" and "thin", and their dependencies.
|
54
|
+
|
55
|
+
Then fire up `irb` and `require 'chook'` to start playing around.
|
56
|
+
|
57
|
+
OR
|
58
|
+
|
59
|
+
run `/usr/local/bin/chook-server` and point some JSS webhooks at `http://my.computer.org/handle_webhook_event`
|
45
60
|
|
46
61
|
## The Framework
|
47
62
|
|
48
63
|
The Chook framework abstracts webhook Events and their components as Ruby
|
49
64
|
classes. When the JSON payload of a JSS webhook POST request is passed into the
|
50
|
-
`Chook::Event.parse_event` method, an instance of the appropriate subclass
|
51
|
-
|
65
|
+
`Chook::Event.parse_event` method, an instance of the appropriate subclass of
|
66
|
+
`Chook::Event` is returned, for example
|
52
67
|
`Chook::Event::ComputerInventoryCompletedEvent`
|
53
68
|
|
54
69
|
Each Event instance contains these important attributes:
|
@@ -104,7 +119,7 @@ All of these file names are valid handlers for ComputerAdded events:
|
|
104
119
|
- COMPUTERAdded_notify_team
|
105
120
|
- Computeradded-update-ldap
|
106
121
|
|
107
|
-
There are two kinds of handlers
|
122
|
+
There are two kinds of handlers, distinguished by their file-executability.
|
108
123
|
|
109
124
|
#### Internal Handlers
|
110
125
|
|
@@ -121,16 +136,70 @@ a handler for a Chook::ComputerAddedEvent
|
|
121
136
|
Chook.event_handler do |event|
|
122
137
|
cname = event.subject.deviceName
|
123
138
|
uname = event.subject.realName
|
124
|
-
|
139
|
+
event.logger.info "Computer '#{cname}' was just added to the JSS for user #{uname}."
|
125
140
|
end
|
126
141
|
```
|
127
142
|
|
128
|
-
|
129
|
-
|
143
|
+
The code block takes one parameter, which will be a Chook::ComputerAddedEvent instance,
|
144
|
+
and in this example stores it in the variable "event."
|
145
|
+
|
130
146
|
It then extracts the "deviceName" and "realName" values from the subject
|
131
|
-
contained in the event, and uses them to
|
147
|
+
contained in the event, and uses them to log a message in the chook log.
|
148
|
+
|
149
|
+
**NameSpacing**
|
150
|
+
|
151
|
+
Be careful when writing internal handlers - they all run in the same Ruby process!
|
152
|
+
|
153
|
+
Not only do they have to be thread-safe, but be wary of cluttering the default
|
154
|
+
namespace with constants that might overwrite each other.
|
155
|
+
|
156
|
+
A good, very ruby-like, practice is to put the guts of your code into a Module or a Class
|
157
|
+
and use that from inside the handler definition. Here's an example using a Class:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
require 'slack-em' # ficticious Slack-chat gem, for demonstation purposes
|
161
|
+
|
162
|
+
class ComputerAdder
|
132
163
|
|
133
|
-
|
164
|
+
SLACK_CHANNEL = '#mac-notifications'
|
165
|
+
|
166
|
+
def initialize(event)
|
167
|
+
@event = event
|
168
|
+
@cname = @event.subject.deviceName
|
169
|
+
end
|
170
|
+
|
171
|
+
def run
|
172
|
+
@event.logger.info "Adder Starting for computer #{@cname}"
|
173
|
+
notify_admins
|
174
|
+
@event.logger.info "Adder Finished for computer #{@cname}"
|
175
|
+
end
|
176
|
+
|
177
|
+
def notify_admins
|
178
|
+
SlackEm.send message: "Computer '#{@cname}' was just added to the JSS for user #{@event.subject.realName}.", channel: SLACK_CHANNEL
|
179
|
+
@event.logger.debug "Admins notified about computer #{@cname}"
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
Chook.event_handler do |event|
|
185
|
+
ComputerAddeder.new(event).run
|
186
|
+
end
|
187
|
+
```
|
188
|
+
|
189
|
+
Here, the handler file defines a 'ComputerAdder' class that does all the work.
|
190
|
+
The handler block merely creates an instance of ComputerAdder with the event,
|
191
|
+
and tells the ComputerAdder instance to run. The instance's run method can
|
192
|
+
then perform any steps desired.
|
193
|
+
|
194
|
+
In this example, the SLACK_CHANNEL constant is defined inside the ComputerAdder class.
|
195
|
+
Access to it from inside the class is done using just the constant itself. If you
|
196
|
+
need to access that particular value from outside of the class, you can
|
197
|
+
use ComputerAdder::SLACK_CHANNEL.
|
198
|
+
|
199
|
+
This way, similar handlers can have their own SLACK_CHANNEL constants and
|
200
|
+
there won't be any interference.
|
201
|
+
|
202
|
+
NOTE: Internal handlers **must not** be executable files. Executability is how the
|
134
203
|
framework determines if a handler is internal or external.
|
135
204
|
|
136
205
|
#### External Handlers
|
@@ -142,7 +211,7 @@ desired. In this case the Chook framework is merely a conduit for passing
|
|
142
211
|
the Posted JSON to the executable program.
|
143
212
|
|
144
213
|
Here's a simple example using bash and [jq](https://stedolan.github.io/jq/) to
|
145
|
-
do the same as the ruby example above:
|
214
|
+
do the same as the first ruby example above:
|
146
215
|
|
147
216
|
```bash
|
148
217
|
#!/bin/bash
|
@@ -235,15 +304,15 @@ the `Chook::Subjects` module.
|
|
235
304
|
|
236
305
|
## The Server
|
237
306
|
|
238
|
-
Chook comes with a simple HTTP server that uses the Chook framework
|
307
|
+
Chook comes with a simple HTTP(S) server that uses the Chook framework
|
239
308
|
to handle all incoming webhook POST requests from the JSS via a single URL.
|
240
309
|
|
241
|
-
To use it you'll need the [sinatra](http://www.sinatrarb.com/)
|
242
|
-
|
310
|
+
To use it you'll need the [sinatra](http://www.sinatrarb.com/) web framework
|
311
|
+
and the [thin](http://code.macournoyer.com/thin/) web server.
|
312
|
+
Both will be installed automatically when you install chook as mentioned below.
|
243
313
|
|
244
|
-
After that, just run the `chook-server` command located in the bin
|
245
|
-
|
246
|
-
http://my_hostname/handle_webhook_event
|
314
|
+
After that, just run the `chook-server` command located in the bin directory
|
315
|
+
for chook and then point your webhooks at: http://my_hostname/handle_webhook_event
|
247
316
|
|
248
317
|
It will then process all incoming webhook POST requests using whatever handlers
|
249
318
|
you have installed.
|
@@ -251,25 +320,163 @@ you have installed.
|
|
251
320
|
To automate it on a dedicated machine, just make a LaunchDaemon plist to run
|
252
321
|
that command and keep it running.
|
253
322
|
|
254
|
-
|
323
|
+
### Server Configuration
|
255
324
|
|
256
|
-
|
325
|
+
The Chook server looks for a config file at `/etc/chook.conf`. If not found, default
|
326
|
+
values are used. Full descriptions of the config values are provided in the sample
|
327
|
+
config file at:
|
328
|
+
/path/to/your/gem/folder/chook-<version>/data/chook.conf.example
|
257
329
|
|
258
|
-
|
330
|
+
Each config setting is on a single line thus: `key: value`. Blank lines and those starting with # are ignored.
|
259
331
|
|
260
|
-
|
332
|
+
Here's a summary:
|
333
|
+
|
334
|
+
- port: The server port
|
335
|
+
- default = 80 or 443
|
336
|
+
- concurrency: Should events be processed simultaneously, or one-at-a time
|
337
|
+
- default = true
|
338
|
+
- handler_dir: The directory holding the andlers to load.
|
339
|
+
- default = /Library/Application Support/Chook
|
340
|
+
- use_ssl: Should the server use SSL (https)
|
341
|
+
- default = false
|
342
|
+
- ssl_cert_path: If SSL is used, the path to the server certificate
|
343
|
+
- no default
|
344
|
+
- ssl_private_key_path: If SSL is used, the path to the certificate key
|
345
|
+
- no default
|
346
|
+
- log_file: The path to the server log file
|
347
|
+
- default = /var/log/chook-server.log
|
348
|
+
- log_level: The severity level for log entries
|
349
|
+
- default = info
|
350
|
+
- logs_to_keep: How many old log files to keep when rotating
|
351
|
+
- default = 10
|
352
|
+
- log_max_megs: How big can a log file get before it's rotated.
|
353
|
+
- default = 10
|
354
|
+
- webhooks_user: The username for Basic Authentication
|
355
|
+
- no default, leave unset for no Authentication
|
356
|
+
- webhooks_user_pw: The file path, or command, to get the password for the webhooks_user.
|
357
|
+
- no default.
|
358
|
+
|
359
|
+
See the sample config file for details about all of these settings.
|
360
|
+
|
361
|
+
### SSL
|
362
|
+
|
363
|
+
It is recommended to use SSL (https) if possible for security, although its beyond the scope
|
364
|
+
of this document to go into a lot of detail about SSL and certificates. That said, here
|
365
|
+
are some pointers:
|
366
|
+
|
367
|
+
- The certificate and key files should be in .pem format
|
368
|
+
|
369
|
+
- Make sure you use a certificate that can be verified by the JSS.
|
370
|
+
- This might involved adding a CA to the JSS's Java Keystore.
|
371
|
+
|
372
|
+
- If running on macOS, the 'thin' webserver and it's underlying 'eventmachine' gem may not
|
373
|
+
like the OS's openssl replacement 'libressl'.
|
374
|
+
- One solution is to use [homebrew](https://brew.sh/) to install openssl and then
|
375
|
+
install eventmachine using that openssl, something like this:
|
376
|
+
|
377
|
+
`brew install openssl ; brew link openssl --force ; gem install eventmachine -- --with-ssl-dir=/usr/local/`
|
378
|
+
|
379
|
+
### Logging
|
380
|
+
|
381
|
+
The Chook server logs activity into the file defined in the `log_file` config setting,
|
382
|
+
`/var/log/chook-server.log` by default.
|
383
|
+
|
384
|
+
It uses a standard ruby [Logger](http://ruby-doc.org/stdlib-2.3.3/libdoc/logger/rdoc/index.html)
|
385
|
+
instance, which provides 5 severity levels: fatal (lowest), error, warn, info, and debug (highest).
|
386
|
+
|
387
|
+
The `log_level` config setting defines the level when the server starts up, and log
|
388
|
+
messages of that level or lower will be written to the log.
|
389
|
+
|
390
|
+
The logger is generally available via `Chook.logger`. If you want to log an exeption with its backtrace, you can use `Chook.log_exception exception` to get the Exception class, message, and backtrace in the log.
|
391
|
+
|
392
|
+
However, for logging from inside handlers, read on...
|
393
|
+
|
394
|
+
#### Logging from handlers
|
395
|
+
|
396
|
+
**Internal handlers**
|
397
|
+
|
398
|
+
To write to the log file from within an internal handler, use the `#logger` method of the `event` object
|
399
|
+
inside the handler block, like so:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
Chook.event_handler do |event|
|
403
|
+
event.logger.debug "This line appears in the log if the level is debug"
|
404
|
+
event.logger.info "This line appears in the log if the level is info or debug"
|
405
|
+
event.logger.error "This line appears in the log if the level is error, warn, info, or debug"
|
406
|
+
end
|
407
|
+
```
|
408
|
+
|
409
|
+
If you want to log an exeption with its backtrace, you can pass the entire exception to the
|
410
|
+
event loggers 'log_exception' method: `event.logger.log_exception exception`
|
411
|
+
|
412
|
+
Log entries written through event objects are preceded with 'Event *event_id*' where *event_id* is
|
413
|
+
an internal ID number for the specific even that wrote the entry.
|
414
|
+
|
415
|
+
|
416
|
+
**External handlers**
|
417
|
+
|
418
|
+
External Handlers can use a URL to make log entries by POSTing to `https://my.chookserver/log`
|
419
|
+
|
420
|
+
The request body must be a JSON object wth 2 keys 'level' and 'message' where both values are strings.
|
421
|
+
The 'level' must be one of the levels mentioned above, and the message is a single line of
|
422
|
+
text.
|
423
|
+
|
424
|
+
If your chook server is using Basic Authentication, it must be provided.
|
425
|
+
|
426
|
+
Here's an example with curl, split to multi-line for clarity:
|
427
|
+
|
428
|
+
```
|
429
|
+
curl -H "Content-Type: application/json" \
|
430
|
+
-X POST \
|
431
|
+
--data '{"level":"debug", "message":"It Worked"}' \
|
432
|
+
https://user:passwd@chookserver.myorg.org/log
|
433
|
+
```
|
434
|
+
|
435
|
+
Messages logged via this url show up in the log preceded by 'ExternalEntry: '
|
436
|
+
|
437
|
+
Any info needed to connect a log entry to a specific event must be included in
|
438
|
+
your log message.
|
439
|
+
|
440
|
+
### Admin Interface
|
441
|
+
|
442
|
+
If you point your web browser at your Chook server, you'll see a simple admin interface.
|
443
|
+
If your server uses Basic Authentication, you'll need to provide the name and password.
|
444
|
+
|
445
|
+
The first section provides a live-stream of the server log file, and provides a way to
|
446
|
+
change the server's log level on the fly. Note that this change affect the server itself
|
447
|
+
not just the view in your browser. If you'd like to stop the stream temporarily (e.g. to
|
448
|
+
select and copy some text from it), just pause and unpause with the checkbox.
|
449
|
+
|
450
|
+
The second section lets you see which handlers are currently loaded, and if they are
|
451
|
+
internal or external. There's also a button to reload the handlers from the handler
|
452
|
+
directory without restarting the server - useful when you add, delete, or modify them.
|
453
|
+
|
454
|
+
The final section just shows your current /etc/chook.conf file, or if there is none,
|
455
|
+
the sample config file is shown, since it shows the default values.
|
456
|
+
|
457
|
+
The admin page cannot be used to edit or upload handlers or change the config. For security
|
458
|
+
reasons, you must do that on the server itself though normal administrative methods.
|
459
|
+
|
460
|
+
### Pointing Jamf Pro at your Chook server
|
461
|
+
|
462
|
+
Once your server is up and running, you can create webhooks in your Jamf Pro interface.
|
261
463
|
|
262
|
-
|
464
|
+
1. Navigate to Settings => Global Management => Webhooks
|
465
|
+
2. Click "New"
|
466
|
+
3. Give your webhook a display name
|
467
|
+
4. Enter the URL for your Chook server, ending with 'handle_webhook_event', e.g:
|
468
|
+
- `http://my.chookserver.edu/handle_webhook_event`
|
469
|
+
- `https://my.chookserver.edu:8443/handle_webhook_event`
|
470
|
+
5. If you use Basic Authentication, enter the name and password
|
471
|
+
6. The default timeouts should be OK, but raise them a bit if you're experiencing errors.
|
472
|
+
7. Set the content type to JSON
|
473
|
+
8. Select the event that triggers the webook
|
474
|
+
9. Click "Enabled" at the top.
|
475
|
+
10. Click "Save"
|
263
476
|
|
477
|
+
Watch the Chook log, with the level at info or debug, to see events come in.
|
264
478
|
|
265
479
|
## TODOs
|
266
480
|
|
267
|
-
- Add SSL support to the server
|
268
|
-
- Improved thread management for handlers
|
269
|
-
- Logging and Debug options
|
270
|
-
- Handler reloading for individual, or all, Event subclasses
|
271
481
|
- Better YARD docs
|
272
|
-
- Better namespace protection for internal handlers
|
273
|
-
- Improved configuration
|
274
482
|
- Proper documentation beyond this README
|
275
|
-
- I'm sure there's more to do...
|
data/bin/chook-server
CHANGED
@@ -24,5 +24,33 @@
|
|
24
24
|
### language governing permissions and limitations under the Apache License.
|
25
25
|
###
|
26
26
|
###
|
27
|
+
|
28
|
+
require 'getoptlong'
|
29
|
+
|
30
|
+
# The CLI options for GetoptLong
|
31
|
+
OPTS = GetoptLong.new(
|
32
|
+
['--log', '-l', GetoptLong::REQUIRED_ARGUMENT],
|
33
|
+
['--dev', '-d', GetoptLong::NO_ARGUMENT]
|
34
|
+
)
|
35
|
+
|
36
|
+
env = :production
|
37
|
+
log_level = nil
|
38
|
+
|
39
|
+
OPTS.each do |opt, arg|
|
40
|
+
case opt
|
41
|
+
when '--log'
|
42
|
+
log_level = arg
|
43
|
+
when '--dev'
|
44
|
+
env = :development
|
45
|
+
end # case
|
46
|
+
end # opts.each
|
47
|
+
|
48
|
+
ENV['APP_ENV'] = env.to_s
|
49
|
+
|
27
50
|
require 'chook/server'
|
28
|
-
|
51
|
+
begin
|
52
|
+
Chook::Server.run! log_level: log_level
|
53
|
+
rescue => e
|
54
|
+
Chook.logger.fatal e.to_s
|
55
|
+
e.backtrace.each { |line| Chook.logger.fatal "..#{line}" }
|
56
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#################
|
2
|
+
# This sample config file uses default settings.
|
3
|
+
#
|
4
|
+
# Each setting is defined on one line like so:
|
5
|
+
#
|
6
|
+
# key: value
|
7
|
+
#
|
8
|
+
# Values may have spaces.
|
9
|
+
#
|
10
|
+
# Blank lines and those starting with # are ignored.
|
11
|
+
|
12
|
+
#################
|
13
|
+
# The port used by the server.
|
14
|
+
# Default: 443 when use_ssl is true, 80 otherwise
|
15
|
+
#
|
16
|
+
port: 80
|
17
|
+
|
18
|
+
#################
|
19
|
+
# By default incoming webhooks are handled in parallel
|
20
|
+
# If you have problems (e.g. a handler isn't thread-safe) try setting this
|
21
|
+
# to false and hooks will be handled one at a time, in the order received.
|
22
|
+
# Default: true
|
23
|
+
#
|
24
|
+
concurrency: true
|
25
|
+
|
26
|
+
#################
|
27
|
+
# The directory holding the internal and external handlers.
|
28
|
+
# Their filenames must start with a known webhook name, and
|
29
|
+
# their executability determines internal (not executable)
|
30
|
+
# versus external (executable). See README.md for details.
|
31
|
+
# Default: /Library/Application Support/Chook
|
32
|
+
#
|
33
|
+
handler_dir: /Library/Application Support/Chook
|
34
|
+
|
35
|
+
#################
|
36
|
+
# Should the server use SSL (https)? Ignored unless the engine is 'thin'
|
37
|
+
# Default: false
|
38
|
+
#
|
39
|
+
use_ssl: false
|
40
|
+
|
41
|
+
#################
|
42
|
+
# When using SSL, the path to the SSL certificate to use, in PEM format
|
43
|
+
# Required if use_ssl == true and engine == thin
|
44
|
+
# Default: none
|
45
|
+
#
|
46
|
+
ssl_cert_path:
|
47
|
+
|
48
|
+
#################
|
49
|
+
# When using SSL, the path to the private key for the SSL certificate, in PEM format
|
50
|
+
# Required if use_ssl == true and engine == thin
|
51
|
+
# Default: none
|
52
|
+
#
|
53
|
+
ssl_private_key_path:
|
54
|
+
|
55
|
+
#################
|
56
|
+
# The path to the file used for chook server logging
|
57
|
+
# Default: /var/log/chook-server.log
|
58
|
+
#
|
59
|
+
log_file: /var/log/chook-server.log
|
60
|
+
|
61
|
+
#################
|
62
|
+
# The detail level for the log. One of:
|
63
|
+
# fatal (only fatal errors logged), error, warn, info, or debug (everything logged)
|
64
|
+
# Default: info
|
65
|
+
#
|
66
|
+
log_level: info
|
67
|
+
|
68
|
+
#################
|
69
|
+
# How many old log files to keep when rotating?
|
70
|
+
# Set to 0, or don't set at all, to disable auto-rotating
|
71
|
+
# of log files.
|
72
|
+
# Default: 10
|
73
|
+
#
|
74
|
+
logs_to_keep: 10
|
75
|
+
|
76
|
+
#################
|
77
|
+
# The log file rotates automatically when it reaches this size in megabytes.
|
78
|
+
# Default: 10
|
79
|
+
#
|
80
|
+
log_max_megs: 10
|
81
|
+
|
82
|
+
#################
|
83
|
+
# Any value here will turn on 'HTTP Basic Authentication' and this will be the username
|
84
|
+
# required to make any connection to the Chook server.
|
85
|
+
# Leaving this empty will allow any connection without authentication
|
86
|
+
# Default: none
|
87
|
+
#
|
88
|
+
webhooks_user:
|
89
|
+
|
90
|
+
#################
|
91
|
+
# When 'HTTP Basic Authentication' is enabled by setting webhooks_user, this
|
92
|
+
# tells chook how to learn the password for that user:
|
93
|
+
#
|
94
|
+
# - If its a path to a file, the file contains the password and nothing else.
|
95
|
+
# The file must be owned by the user running the chook server, and must have
|
96
|
+
# mode 0600.
|
97
|
+
#
|
98
|
+
# - If it ends with a pipe character (|), everything execpt the pipe is considered
|
99
|
+
# to be a shell command, executable by the user running the chook server.
|
100
|
+
# The standard-output of the command will be the password.
|
101
|
+
#
|
102
|
+
# Default: none
|
103
|
+
#
|
104
|
+
webhooks_user_pw:
|