[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Communicate with a daemon

Paul A.

5/10/2009 9:22:00 PM

Hello everyone,

After daemonize a Ruby process (thanks Ruby version 1.9), it is possible
to communicate with on the same machine by using socket on localhost. Do
you know some other methods instead of socket?

Thanks.
--
Posted via http://www.ruby-....

6 Answers

Bill Kelly

5/10/2009 9:40:00 PM

0


From: "Paul A." <cyril.staff@gmail.com>
>
> After daemonize a Ruby process (thanks Ruby version 1.9), it is possible
> to communicate with on the same machine by using socket on localhost. Do
> you know some other methods instead of socket?

Perhaps http://localmemcache.ruby...


Regards,

Bill



James Gray

5/10/2009 10:32:00 PM

0

On May 10, 2009, at 4:22 PM, Paul A. wrote:

> After daemonize a Ruby process (thanks Ruby version 1.9), it is
> possible
> to communicate with on the same machine by using socket on
> localhost. Do
> you know some other methods instead of socket?

Sure. In I daemon I've been working on, I just use SQLite as a queue
for messages. I use the Amalgalite extension, which is terrific and
works well on Ruby 1.9.

When you're going to write to the queue, make sure to grab an
"exclusive" lock (via the "transaction" SQL command). When reading,
grab an "immediate" lock first. Set a busy handler through Amalgalite
that retries for a reasonable time (I use 60 seconds) to grab locks.
Add some error handling code for if the lock wait does eventually
timeout, but that shouldn't happen under normal operations.

About the only challenges I ran into were deleting data from the
queue. Deleting counts as a write, so grab an "exclusive" lock. That
was easy of course. The downside is that the SQLite database needs to
have the "vacuum" command run on it every so often to reclaim wasted
disk space. You can't be holding a lock when you do that though.
Thus I locked on an external source about once a day, and vacuumed the
database. If it's just a simple queue you need (with no long term
storage), you could also just nuke the file and rebuild it periodically.

Anyway, I hope that gives you some fresh ideas.

James Edward Gray II


Robert Klemme

5/11/2009 6:25:00 AM

0

On 10.05.2009 23:22, Paul A. wrote:
> After daemonize a Ruby process (thanks Ruby version 1.9), it is possible
> to communicate with on the same machine by using socket on localhost. Do
> you know some other methods instead of socket?

You have got the whole range of IPC at your fingertips

- named FIFO,
- unnamed FIFO if the client is a child process of your daemon,
- Unix domain socket (only on the local machine),
- signals,
- shared memory (with proper locking, e.g. via semaphores),
....

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestprac...

Brian Candler

5/11/2009 9:17:00 AM

0

Robert Klemme wrote:
> On 10.05.2009 23:22, Paul A. wrote:
>> After daemonize a Ruby process (thanks Ruby version 1.9), it is possible
>> to communicate with on the same machine by using socket on localhost. Do
>> you know some other methods instead of socket?
>
> You have got the whole range of IPC at your fingertips
>
> - named FIFO,
> - unnamed FIFO if the client is a child process of your daemon,
> - Unix domain socket (only on the local machine),
> - signals,
> - shared memory (with proper locking, e.g. via semaphores),
> ...

And don't forget the simple DRb, if both ends are Ruby:

http://web.archive.org/web/20070217144414rn_1/wiki.rubygarden.org/Ruby/page/show/D...

Also XMLRPC (included in the Ruby standard library, at least it was for
1.8, don't know if it's still in 1.9), and also plenty of ways to embed
a HTTP server into your application (e.g. Webrick, Sinatra)
--
Posted via http://www.ruby-....

Yisroel Markov

6/13/2014 2:40:00 PM

0

On Fri, 13 Jun 2014 01:37:52 +0000 (UTC), Giborah
<hypatia08@gmail.com> said:

>On Thursday, June 12, 2014 2:14:14 PM UTC-7, Yisroel Markov wrote:
>> On Thu, 12 Jun 2014 17:38:36 +0000 (UTC), Giborah
>>
>> <hypatia08@gmail.com> said:
>>
>>
>>
>> >[ Moderator's Comment: I don't know of any way to get get it other than
>>
>> > your outbox if you news program saves it. hw ]
>>
>> >My post on this never appeared,
>>
>>
>>
>> And that's a good thing. Let's not inject politics into this NG. (The
>>
>> charter and all that.)
>>
>Wasn't about politics.

"Cantor is history" isn't about politics? Well, well.

>But thanks for telling me, sight unseen, what I was saying. Looks like there's a mini-club in formation to tell people what they mean. Called determination bias.

For the n'th time, that's not what it's called. Humans have many
biases already; why invent another?

>You see what you want to see.

But didn't you just say that there was nothing to see?
--
Yisroel "Godwrestler Warriorson" Markov - Boston, MA Member
www.reason.com -- for a sober analysis of the world DNRC
--------------------------------------------------------------------
"Judge, and be prepared to be judged" -- Ayn Rand

mm

6/17/2014 6:03:00 PM

0

On Fri, 13 Jun 2014 01:37:52 +0000 (UTC), Giborah <hypatia08@gmail.com>
wrote:

>On Thursday, June 12, 2014 2:14:14 PM UTC-7, Yisroel Markov wrote:
>> On Thu, 12 Jun 2014 17:38:36 +0000 (UTC), Giborah
>>
>> <hypatia08@gmail.com> said:
>>
>>
>>
>> >[ Moderator's Comment: I don't know of any way to get get it other than
>>
>> > your outbox if you news program saves it. hw ]
>>
>> >My post on this never appeared,
>>
>>
>>
>> And that's a good thing. Let's not inject politics into this NG. (The
>>
>> charter and all that.)
>>
>Wasn't about politics. But thanks for telling me, sight unseen, what I was saying.

So he guessed and he was wrong. Big deal.

> Looks like there's a mini-club in formation to tell people what they mean. Called determination bias. You see what you want to see.

It was a prediction, not a vision.

>G.

--

Meir
It is better to eat an onion in Jerusalem than a cockerel in Egypt. 1055CE