Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 20152 invoked from network); 13 Feb 2011 18:26:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Feb 2011 18:26:36 -0000 Received: (qmail 38959 invoked by uid 500); 13 Feb 2011 18:26:35 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 38802 invoked by uid 500); 13 Feb 2011 18:26:32 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 38794 invoked by uid 99); 13 Feb 2011 18:26:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 18:26:32 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of amine.benhamza@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 18:26:24 +0000 Received: by iyh42 with SMTP id 42so4191944iyh.11 for ; Sun, 13 Feb 2011 10:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=sXET25rG34fZlKAjK7e2JwXMKnttq0OV/TM6B5hGXR8=; b=KR3mSHcF8rY5R1lLS/2fjCDRqcjWDh5v4kCGiLNVDFnDHrUHk+Dk7zW+zUvcNIAgOh l/L15Ubb8zlVSYhn3cbuniXP4Ar6rMszT2muDyExNN4AA530T3q1SYNGBAm9mLCR5B1J fDIpTU+Fn4HEqFcLJRlqXWCIK9hffksYOAPog= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=RkejKfFVDFIxJHPfsn01e13p+H8bOxb1xA0bddvdtFLHmi5HTjviYGpNVgovoEZDbu fLylqxT1xlIWf0GZfAFfRa6M2lZ4r7pRL6ymlZp3mdJzy3jei3nzrW95ENtUaJpD18or /UZaK+ReOC3PF6+A4lP3gPQzx7Q6UQ6QQhBQo= Received: by 10.42.176.68 with SMTP id bd4mr3717694icb.408.1297621563197; Sun, 13 Feb 2011 10:26:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.191.145 with HTTP; Sun, 13 Feb 2011 10:25:43 -0800 (PST) In-Reply-To: References: <4D58099A.1090701@gmx.net> From: Amine BENHAMZA Date: Sun, 13 Feb 2011 19:25:43 +0100 Message-ID: Subject: Re: External process - Having trouble Half the time To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e8ef053c7a9049c2e106b X-Virus-Checked: Checked by ClamAV on apache.org --90e6ba6e8ef053c7a9049c2e106b Content-Type: text/plain; charset=ISO-8859-1 Thanks Guys for you response. That's my code : require "rubygems" require "resque" require "tweetstream" require 'job' STDOUT.puts "{" + '"code":200' + "," + '"headers":{"Content-Type":""}' + "," + '"json":{}' + "}" module Demo Resque.enqueue(Job, 'egypt') end STDOUT.flush The next version of the code is to parameter the keyword (brought for form) from STDIN. So I'll run this instead Resque.enqueue(Job, keyword). The Job I'm putting in queue is Twitter Streaming for a given keyword(s). At the origin, my script was : require 'rubygems' require 'tweetstream' require 'couchrest' STDOUT.puts "{" + '"code":200' + "," + '"headers":{"Content-Type":""}' + "," + '"json":{}' + "}" @db = CouchRest::database!('trends_monitoring_bis') #This will pull a sample of all tweets based on your Twitter account's Streaming API role. TweetStream::Client.new('aminedigirep','password').track('algerie') do |status| puts "#{status.user.screen_name} : #{status.text}" @db.save_doc(status) end STDOUT.flush This script works fine for the first call, once you run the script for another keyword, It blocks the first call. So I decided to put my job in queue and get back to couchdb to end the external process, so doing away from couchdb. *"the most common mistake is to forget to loop. an external handler is expected to stay running for lots of requests, not exit on every request like CGI."* I didn't know that. It make sens. The "_changes" is good option. Do you know a good way to implement it ? Node.js ? Another option ? I found this example : http://www.joeandmotorboat.com/2010/01/01/fun-with-the-couchdb-_changes-feed-and-rabbitmq/I didn't get it very well. It uses Yajl and RabittMQ. I'll try to combine Yajl and Resque (very accessible a MQ engine). Cheers ! On 13 February 2011 18:01, Robert Newson wrote: > I'd completely missed that content-type was set to "Content-Type". :) > > On 13 February 2011 16:40, Martin Hilbig wrote: > > hi, > > > > On 13.02.2011 16:55, Amine BENHAMZA wrote: > >> > >> Hello Guys, > >> > >> I'm working to launch an external process (ruby script) from couchdb. > Half > >> the time, I have this error : "error":"{noproc,{gen_server,call, (i omit > >> the > >> rest). The full log is here : https://gist.github.com/824762 > >> > >> I'm launching the external process this way : > >> http://127.0.0.1:5984/trends_monitoring3/_rts > >> > >> The code I'm running aims to add a Job to Resque queue ( > >> https://github.com/defunkt/resque) as done below : > >> > >> STDOUT.puts "{" + '"code":200' + "," + > >> '"headers":{"Content-Type":"Content-Type"}' + "," + '"json":{}' + "}" > > > > i don't know whether this is a problem, but are you sure to set a > > Content-Type header with value Content-Type not application/json? but > then > > you send a json body, i think you can simple omit the header. > > > > on the other hand your log suggests, that the caller expects > text/html/xml > > but not json, so maybe you want to change the "json":{} to "body":"". > > > > the last point: this script exits after it handled one request right? but > > couchdb expects the _external to continue running and handlich more > > requests, so you should put some loop around your code. > > > > others maybe would also suggest to use the _changes api instead ;) > > > > have fun > > martin > > > >> module Demo > >> Resque.enqueue(Job, params) > >> end > >> > >> STDOUT.flush > >> > >> Did someone face this issue ? Have you any idea about what could cause > >> this > >> ? > >> > >> Thanks > >> > >> Amine. > >> > > > --90e6ba6e8ef053c7a9049c2e106b--