Class: RailsParallel::Rake
- Inherits:
-
Object
- Object
- RailsParallel::Rake
- Includes:
- Singleton
- Defined in:
- lib/rails_parallel/rake.rb
Constant Summary collapse
- SCHEMA_DIR =
'tmp/rails_parallel/schema'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.launch ⇒ Object
12 13 14 |
# File 'lib/rails_parallel/rake.rb', line 12 def self.launch instance.launch end |
.run(name, ruby_opts, files) ⇒ Object
16 17 18 19 |
# File 'lib/rails_parallel/rake.rb', line 16 def self.run(name, ruby_opts, files) instance.launch instance.run(name, ruby_opts, files) end |
Instance Method Details
#launch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_parallel/rake.rb', line 21 def launch return if @pid at_exit { shutdown } create_test_db my_socket, c_socket = ObjectSocket.pair sock = c_socket.socket sock.fcntl(Fcntl::F_SETFD, sock.fcntl(Fcntl::F_GETFD, 0) & ~Fcntl::FD_CLOEXEC) @pid = fork do my_socket.close ENV['RAILS_PARALLEL_ROOT'] = Rails.root exec('rails_parallel_worker', sock.fileno.to_s) raise 'exec failed' end c_socket.close @socket = my_socket expect(:started) end |
#run(name, ruby_opts, files) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails_parallel/rake.rb', line 44 def run(name, ruby_opts, files) = (ruby_opts) schema = schema_file expect(:ready) @socket << { :name => name, :schema => schema, :options => , :files => files.to_a } expect(:done) end |
#shutdown ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/rails_parallel/rake.rb', line 58 def shutdown if @pid @socket << :shutdown Process.waitpid(@pid) @pid = nil end end |