1 |
|
2 | require('coffee-script').register()
|
3 |
|
4 | async = require 'async'
|
5 | path = require 'path'
|
6 |
|
7 | bobbin = require '../src/bobbin.coffee'
|
8 |
|
9 | async.series [
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | (example_cb) ->
|
15 | bobbin.create (err, pool) ->
|
16 | return example_cb(err) if err?
|
17 |
|
18 |
|
19 | work_function = (n, callback) ->
|
20 | console.log "Hello World #{n}!"
|
21 | callback()
|
22 |
|
23 |
|
24 | async.times 5, (n, callback) ->
|
25 |
|
26 |
|
27 | pool.run n, work_function, callback
|
28 |
|
29 | , (err) ->
|
30 | return example_cb(err) if err?
|
31 | console.log 'Example 1 Done!\n'
|
32 | example_cb()
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | , (example_cb) ->
|
38 |
|
39 | opts = {
|
40 | work_dir: path.resolve(__dirname, './path/name/injection/example/')
|
41 | num_workers: 5
|
42 | }
|
43 |
|
44 |
|
45 | bobbin.create opts, (err, pool) ->
|
46 | return example_cb(err) if err?
|
47 |
|
48 |
|
49 |
|
50 | work_function = (callback) ->
|
51 | console.log require('./module.coffee')
|
52 | callback()
|
53 |
|
54 |
|
55 | pool.run work_function, (err) ->
|
56 | return example_cb(err) if err?
|
57 | console.log 'Example 2 Done!\n'
|
58 | example_cb()
|
59 |
|
60 |
|
61 |
|
62 | ], (err) ->
|
63 | if err?
|
64 | console.error 'There was an error!'
|
65 | console.error err
|
66 | console.trace err
|
67 | process.exit -1
|
68 |
|
69 | console.log 'Examples finished!'
|
70 | process.exit 0 |
\ | No newline at end of file |