|
70 | 70 |
|
71 | 71 | (schema/defn ^:always-validate
|
72 | 72 | prime-pool!
|
73 |
| - "Sequentially fill the pool with new JRubyInstances. NOTE: this |
74 |
| - function should never be called except by the modify-instance-agent |
75 |
| - to create a pool's initial jruby instances." |
| 73 | + "Fill the pool with new JRubyInstances. Instantiates the first JRuby (Puppet |
| 74 | + will sometimes alter the filesystem on first instantiation) and the remaining |
| 75 | + instances in parallel. NOTE: this function should never be called except by |
| 76 | + the modify-instance-agent to create a pool's initial jruby instances." |
76 | 77 | [{:keys [config] :as pool-context} :- jruby-schemas/PoolContext]
|
77 | 78 | (log/debug (format "%s\n%s"
|
78 | 79 | (i18n/trs "Initializing JRubyInstances with the following settings:")
|
79 | 80 | (ks/pprint-to-string config)))
|
80 | 81 | (let [pool (jruby-internal/get-pool pool-context)
|
81 | 82 | creation-service (jruby-internal/get-creation-service pool-context)
|
82 | 83 | total (.remainingCapacity pool)
|
83 |
| - ids (->> total range (map inc)) |
| 84 | + [first-id & ids] (->> total range (map inc)) |
84 | 85 | add-instance* (fn [id]
|
85 | 86 | (log/debug (i18n/trs "Priming JRubyInstance {0} of {1}"
|
86 | 87 | id count))
|
87 | 88 | (add-instance pool-context id)
|
88 | 89 | (log/info (i18n/trs "Finished creating JRubyInstance {0} of {1}"
|
89 | 90 | id count)))
|
| 91 | + initial-task (fn [] (add-instance* first-id)) |
90 | 92 | tasks (for [id ids] (fn [] (add-instance* id)))]
|
91 |
| - (execute-tasks! tasks creation-service))) |
| 93 | + (execute-tasks! [initial-task] creation-service) |
| 94 | + (when (seq ids) |
| 95 | + (execute-tasks! tasks creation-service)))) |
92 | 96 |
|
93 | 97 | (schema/defn ^:always-validate
|
94 | 98 | flush-instance!
|
|
0 commit comments