FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-27-2010, 07:52 PM
Israel Garcia
 
Default daemonizing a command

Hi,

I need to daemonize this command on a debian lenny?

ruby apd.rb

It's a simple app for my network.

I was thinking to use nohup ruby app.rb & at rc.local, but I want to
know if there's other ways to do it.

--
Regards;
Israel Garcia


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail .gmail.com">http://lists.debian.org/AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail .gmail.com
 
Old 05-27-2010, 07:59 PM
Neal Hogan
 
Default daemonizing a command

On Thu, May 27, 2010 at 2:52 PM, Israel Garcia <igalvarez@gmail.com> wrote:
> Hi,
>
> I need to daemonize this command on a debian lenny?
>
> ruby apd.rb
>
> It's a simple app for my network.
>
> I was thinking to use nohup ruby app.rb & at rc.local, but I want to
> know if there's other ways to do it.

It's been awhile since I wrote such a script, so the details aren't at
the tip of my tongue, but the following helped me when I did. Perhaps
it will help.

http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian

>
> --
> Regards;
> Israel Garcia
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail .gmail.com
>
>


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTimMnsaO83pbA4bbgPjMGeI8fl8vx7pqG1QhtO3I@mail .gmail.com">http://lists.debian.org/AANLkTimMnsaO83pbA4bbgPjMGeI8fl8vx7pqG1QhtO3I@mail .gmail.com
 
Old 05-27-2010, 08:05 PM
Ron Johnson
 
Default daemonizing a command

On 05/27/2010 02:52 PM, Israel Garcia wrote:

Hi,

I need to daemonize this command on a debian lenny?

ruby apd.rb

It's a simple app for my network.

I was thinking to use nohup ruby app.rb& at rc.local, but I want to
know if there's other ways to do it.



Using Python, I create a module named daemonize and then at the
beginning of any program I want to run as a daemon, I do:

import daemonize
daemonize.daemonize()

Maybe you can convert this code to Ruby...

# Daemon Module - basic facilities for becoming a daemon process
# written by Coy Krill (ckrill@qvlinc.com)
#
# Combines ideas from Steinar Knutsens daemonize.py and
# Jeff Kunces demonize.py

"""Facilities for Creating Python Daemons"""

import os
import time
import sys

class NullDevice:
def write(self, s):
pass

def daemonize():
if (not os.fork()):
# get our own session and fixup std[in,out,err]
os.setsid()
sys.stdin.close()
sys.stdout = NullDevice()
sys.stderr = NullDevice()
if (not os.fork()):
# hang around till adopted by init
ppid = os.getppid()
while (ppid != 1):
time.sleep(0.5)
ppid = os.getppid()
else:
# time for child to die
os._exit(0)
else:
# wait for child to die and then bail
os.wait()
sys.exit()


--
Dissent is patriotic, remember?


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4BFED092.3010605@cox.net">http://lists.debian.org/4BFED092.3010605@cox.net
 
Old 05-27-2010, 10:56 PM
Carl Johnson
 
Default daemonizing a command

Israel Garcia <igalvarez@gmail.com> writes:

> Hi,
>
> I need to daemonize this command on a debian lenny?
>
> ruby apd.rb
>
> It's a simple app for my network.
>
> I was thinking to use nohup ruby app.rb & at rc.local, but I want to
> know if there's other ways to do it.

Have you looked at the libdaemons-ruby package to see if it helps?

--
Carl Johnson carlj@peak.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87sk5dq7gy.fsf@cjlinux.localnet">http://lists.debian.org/87sk5dq7gy.fsf@cjlinux.localnet
 
Old 05-28-2010, 07:43 AM
Israel Garcia
 
Default daemonizing a command

On Thu, May 27, 2010 at 9:59 PM, Neal Hogan <nealhogan@gmail.com> wrote:
> On Thu, May 27, 2010 at 2:52 PM, Israel Garcia <igalvarez@gmail.com> wrote:
>> Hi,
>>
>> I need to daemonize this command on a debian lenny?
>>
>> ruby apd.rb
>>
>> It's a simple app for my network.
>>
>> I was thinking to use nohup ruby app.rb & at rc.local, but I want to
>> know if there's other ways to do it.
>
> It's been awhile since I wrote such a script, so the details aren't at
> the tip of my tongue, but the following helped me when I did. Perhaps
> it will help.
>
> http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian
Hi Neal,

I did it this way.. look my init script :-)

#! /bin/sh
# /etc/init.d/apd
#

# Some things that run always

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting postfix policy daemon...."
sleep 1
ruby /usr/local/bin/apd.rb & > /dev/null
echo "" > /dev/null
;;
stop)
echo "Stopping postfix policy daemon...."
sleep 1
kill -9 `ps afx|grep "ruby /usr/local/bin/apd.rb"|grep -v
grep|awk '{print $1}'` >/dev/null
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/apd {start|stop|restart}"
exit 1
;;
esac

exit 0

>
>>
>> --
>> Regards;
>> Israel Garcia
>>
>>
>> --
>> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
>> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>> Archive: http://lists.debian.org/AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail .gmail.com
>>
>>
>



--
Regards;
Israel Garcia


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTik2t52eckeyPk8cE1dlNVzML0Oleu1D_yediot1@mail .gmail.com">http://lists.debian.org/AANLkTik2t52eckeyPk8cE1dlNVzML0Oleu1D_yediot1@mail .gmail.com
 
Old 05-28-2010, 11:40 AM
Neal Hogan
 
Default daemonizing a command

On Fri, May 28, 2010 at 2:43 AM, Israel Garcia <igalvarez@gmail.com> wrote:
> On Thu, May 27, 2010 at 9:59 PM, Neal Hogan <nealhogan@gmail.com> wrote:
>> On Thu, May 27, 2010 at 2:52 PM, Israel Garcia <igalvarez@gmail.com> wrote:
>>> Hi,
>>>
>>> I need to daemonize this command on a debian lenny?
>>>
>>> ruby apd.rb
>>>
>>> It's a simple app for my network.
>>>
>>> I was thinking to use nohup ruby app.rb & at rc.local, but I want to
>>> know if there's other ways to do it.
>>
>> It's been awhile since I wrote such a script, so the details aren't at
>> the tip of my tongue, but the following helped me when I did. Perhaps
>> it will help.
>>
>> http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian
> Hi Neal,
>
> I did it this way.. look my init script :-)
>
> #! /bin/sh
> # /etc/init.d/apd
> #
>
> # Some things that run always
>
> # Carry out specific functions when asked to by the system
> case "$1" in
> *start)
> * *echo "Starting postfix policy daemon...."
> * *sleep 1
> * *ruby /usr/local/bin/apd.rb & > /dev/null
> * *echo "" * > /dev/null
> * *;;
> *stop)
> * *echo "Stopping postfix policy daemon...."
> * *sleep 1
> * * kill -9 `ps afx|grep "ruby /usr/local/bin/apd.rb"|grep -v
> grep|awk '{print $1}'` >/dev/null
> * *;;
> restart)
> * * * *$0 stop
> * * * *sleep 1
> * * * *$0 start
> * * * *;;
> **)
> * *echo "Usage: /etc/init.d/apd {start|stop|restart}"
> * *exit 1
> * *;;
> esac
>
> exit 0


It looks fine to me. If it does what you want, great!

Thanks for showing me.

-Neal


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTikjvBpKUUHkVEGyTr-CyCPSEgVKo96AwAdBHkfo@mail.gmail.com">http://lists.debian.org/AANLkTikjvBpKUUHkVEGyTr-CyCPSEgVKo96AwAdBHkfo@mail.gmail.com
 

Thread Tools




All times are GMT. The time now is 12:15 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org