multicore
Multi-process launch of Crystal app
Installation
-
Add the dependency to your
shard.yml
:dependencies: multicore: github: Hentioe/multicore.cr
-
Run
shards install
Usage
require "multicore"
def start
process_id = ENV["MULTICORE_ID"]?
puts "Starting process: #{process_id}" if process_id
sleep
end
Multicore.startup(4) do
start
end
# => Starting process: 1
# => Starting process: 2
# => Starting process: 3
# => Starting process: 4
The meaning of the first parameter n
of Multicore#startup
:
n < 0
, No fork new process, nothing happensn == 0
, The number of processes is the number of CPUsn > 0
, Specify the number of processes
Contributing
- Fork it (https://github.com/Hentioe/multicore.cr.git)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Hentioe - creator and maintainer