From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=0.0 required=3.0 tests=MSGID_FROM_MTA_HEADER, TVD_RCVD_IP shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Alexandre Riveira Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: background threads Date: Mon, 18 Jun 2012 19:08:16 +0000 Message-ID: <4FDF7CA0.6030103@objectdata.com.br> References: <4FDF7420.7030300@objectdata.com.br> <20120618215550.GA31162@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1340057394 3898 80.91.229.3 (18 Jun 2012 22:09:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 18 Jun 2012 22:09:54 +0000 (UTC) Cc: Rainbows! list To: Eric Wong Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue Jun 19 00:09:53 2012 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=gME/3rDa5NDHx+rn0h8BLEr1IKt8jygeBVNdMwnVBsY=; b=OLBBWRx8C25Go7uz99b6DcU5dd200JTj8OGsV08BL0MjuNbsOlW2Up6q9nDebFpAgB 5EzdtKR/lNM0vZ/F4/GKnz6iSAD04i+en6SBrYOTfNw/OG6UrsKlw+nLFH97ZOKu1XLY VrqZkSzGUT3xGiYrKXuclBmEixPihhRkUbT+IKj++lAiQoh98tYyX4KnjD8d/JwYHBXL d2Vl82MPehEfdReQwRBxp/xXkM86zOjyxwkITpHSM4mwNXKJ+GTr7PJVXrymz3lLiqoO e3B6obqXSYGiDoM/pc7EdMBX3muuhz7SQYfZ7sabaOudIcmY0iUr/Uqw5rAf3yVGVmZ4 mq9Q== User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.4) Gecko/20120421 Thunderbird/10.0.4 In-Reply-To: <20120618215550.GA31162-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> X-Gm-Message-State: ALoCoQkPOc4MgV9f5PhpsOfIC3GYeDqdbtgnvOCYZ+7VtOHd+Af+WtxrtpE3aWsZHO7GKtMdbSqJ X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:361 Archived-At: Received: from 50-56-192-79.static.cloud-ips.com ([50.56.192.79] helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sgk8r-0008I7-0k for gclrrg-rainbows-talk@m.gmane.org; Tue, 19 Jun 2012 00:09:49 +0200 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 3A4B62E06E; Mon, 18 Jun 2012 22:09:48 +0000 (UTC) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by rubyforge.org (Postfix) with ESMTP id 23FA82E06C for ; Mon, 18 Jun 2012 22:08:03 +0000 (UTC) Received: by yenl6 with SMTP id l6so5048942yen.23 for ; Mon, 18 Jun 2012 15:08:03 -0700 (PDT) Received: by 10.236.154.193 with SMTP id h41mr19737661yhk.58.1340057282893; Mon, 18 Jun 2012 15:08:02 -0700 (PDT) Received: from [192.168.0.125] ([189.78.153.40]) by mx.google.com with ESMTPS id f8sm27387057anm.16.2012.06.18.15.08.01 (version=SSLv3 cipher=OTHER); Mon, 18 Jun 2012 15:08:02 -0700 (PDT) Em 18-06-2012 21:55, Eric Wong escreveu: What kind of problems? The application consumes 100% cpu after reload Is preload_app true or false? (default is false) preload_app is true I changed my code as below and got a result in small servers Thread.new(log) do |rotina_log| loop do log.info("rotina automatica") {"waiting process before end"} sleep(5) break unless File.exists? Dir.pwd + '/tmp/pids/rainbows.pid.oldbin' end loop do #rotina_log.info("rotina automatica") { "waiting 60 secs #{Process.pid}" } sleep(60) if $0.include? "old" rotina_log.info("rotina automatica") { "exit..... #{Process.pid}" } Thread.exit end begin #rotina_log.info("rotina automatica") { "exec #{Process.pid}" } empresas = Empresa::Base.find_all_by_cancelado(false) #sleep(180) empresas.invoke(:rotinas_automaticas, :usuario_id => Auth::Configuracao.instance.usuario_sistema_id) #rotina_log.info("rotina automatica") { "exec ok #{Process.pid}" } rescue Exception => e rotina_log.fatal("rotina automatica") { e.to_s + e.backtrace.inspect } end end end Tanks, Alexandre Riveira Brazil _______________________________________________ Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying