Sunday 15 April 2012

ruby on rails - Sidekiq worker not able to write to database or log file -


I am creating an app on Herokou and Redis which sends an SMS message to an input CSV file for each line In which the mobile phone number The message has been sent down to a sidekick worker using the twilio. The problem is that even if the SMS is being sent for all the rows in the CSV, write the database ( TextMessage.create) and logs written ( puts statements) Only in CSV there is a sidekick worker created for each line in the CSV file for the A line. It seems that only one sidekick worker has I / O (DB, file) access and it locks it with other sidekick workers. Any help would be appreciated.

Sidekick Worker:

  'sidekiq' is required 'tileio-rb' class texceptions & lt; ActiveRecord :: Base included Sidekiq :: Extensions def self.send_message (number, body, ROW_INDEX, column_index, table_id) "TextMessage # send_message: row index: # {ROW_INDEX} column index: # {column_index} TableID: # {} Table_id body: # {body} phone: # {number} "tileio :: configuration setup: account_sid = & gt; 'Vague' ,: auth_token = & gt; '& Lt; Unclear & gt; ' Sms = twilio :: sms Create: from = & gt; Number, = to = & gt; '+17085555555' ,: body = & gt; Body + '| Sent: '+ Time.now.in_time_zone (' Central Time (US & Canada) '). Striptime ("% m /% d /% Y% I:% M% p central") TextMessage.create: to = & gt; Number, = to = & gt; '+17085555555' ImportCell.add_new_column (table_id, ROW_INDEX, column_index, "Time to Sent", Time.now.in_time_zone ('Central Time (USA & Canada)'.) Strftime ("% M /% d /% Y% I:% M% p Central ")) End end   

Call the sidecake worker:

  TextMessage .delay_until (time_to_send,: GT retry = &, 3) .send_message (Phone, 'scheduled:' + time_to_send.in_time_zone ('Central Time (USA & Canada)') strftime ("% M /% d / % Y% I:.% M% P central "), line_index, column_index, table.idem column_index + = 1   

Worker: Bundle Exclusive Sidekick -C Config / SideKeak.IML

< Code> Sidekick.IML

 : verbose: false: concurrency: 3: line: - [default, 5]   

config / initializers / redis.rb :

  uri = URI.parse (ENV ["REDISTOGO_URL"]) REDIS = Redis New (: host = & gt; Uri.host ,: port = & gt; Uri.port,: Password = & gt; Uri.password) Sidekiq.config Ure_server do | Config | Database_url = ENV ['DATABASE_URL'] If (database_url) ENV ['DATABASE_URL'] = "# {database_url}" pool = 25 "ActiveRecord :: Base.establish_connection End End    < P> 

I am one of those people who commented on your question, just decided it!

You're using .create which sidekick did not look like this, so I tried. New and used again. I think what to do with it. The thread is not being compressed or some kind of safe, but I honestly do not know anything.

Non-working code:

  Class Hardwalker Sidekick :: Worker def (name, count) display 'some are working hard!' UserInfo.create (: user = & gt; "any",: misc1 = & gt; 0 ,: misc2 =>,: misc3 ​​= & gt; 0 ,: comment = & gt; "created from hardworker ",: Time_changed = & gt; time.) Now 'done with hard work'! Working Code:  
  Class Hardwalkers include Sidekick :: Worker Diff (name, count) 'Some work hard!' A_row = UserInfo.new (: user = & gt; "any",: misc1 =>,: misc2 =>, misc3 ​​=> 0 ,: comment => "hardworker Created from ",: time_changed = & gt; time.nah) 'a_row.save' with hard work! ' End End    

No comments:

Post a Comment