Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I'd like to run a Python / Django program as a init.d startup script. The script line is: python manage.py runserver 192.168.0.2:8181 The problem: when it runs it spits out ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    6

    Running python script on boot

    I'd like to run a Python / Django program as a init.d startup script. The script line is:

    python manage.py runserver 192.168.0.2:8181

    The problem: when it runs it spits out messages to the console until I kill it with Ctrl C.

    How can I change the script or add some pipes to overcome this problem ?

    Any comments or suggestion is welcome!
    Thanks in advance,
    Josir Gomes
    Rio de Janeiro - Brasil

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    you can try putting into background ? using &

  3. #3
    Linux User Giles's Avatar
    Join Date
    May 2005
    Location
    Gloucestershire and Cambridge, UK
    Posts
    283
    Or try sending the output to /dev/null?

    Code:
    python manage.py runserver 192.168.0.2:8181 > /dev/null
    Giles
    "Our greatest fear is not that we are powerless. Our greatest fear is Microsoft"
    Registered linux user #391027

  4. #4
    Just Joined!
    Join Date
    Sep 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    6
    Hi folks, thanks for replying.

    /dev/null will not work. It will simply omit the output but it will wait for a input anyway.

    How can I use the & in the init.d script?
    Where can I find some info about backgrounding the script?

    Thanks in advance,
    Josir Gomes

  5. #5
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by josir View Post
    Hi folks, thanks for replying.

    /dev/null will not work. It will simply omit the output but it will wait for a input anyway.

    How can I use the & in the init.d script?
    Where can I find some info about backgrounding the script?

    Thanks in advance,
    Josir Gomes
    put & at the end of your command. Google is your best friend. type "Unix background &" in google. Or type "advanced bash"

  6. #6
    Just Joined!
    Join Date
    Sep 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    6

    Ginap

    Hi Ghostdog,

    GINAP: Google Is Not A Professional...
    That is, if Google could solve everything, we would not need a forum...

    if you read carefully, you will see that I want to use the "&" with the update.rc command and init.d procedures.

    Let me explain myself better: "What are the pitfalls if I use the & inside my script and deploy it with update.rc ? Is this correct in the LSB directives ?"

    Thanks anyway: with your post, I could explain better my doubt.
    Josir Gomes

  7. #7
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by josir View Post
    Hi Ghostdog,

    GINAP: Google Is Not A Professional...
    That is, if Google could solve everything, we would not need a forum...
    you may be right, but it does solve most things, if you know how to find.

    if you read carefully, you will see that I want to use the "&" with the update.rc command and init.d procedures.
    no where in your posts did you say you want to use it with update.rc, or have i missed it?

    Let me explain myself better: "What are the pitfalls if I use the & inside my script and deploy it with update.rc ? Is this correct in the LSB directives ?"

    Thanks anyway: with your post, I could explain better my doubt.
    Josir Gomes
    i don't have update.rc, so i won't comment on this
    please try this and see. :
    Code:
    python manage.py runserver 192.168.0.2:8181 &
    Otherwise, you can also code your python script (or runserver? ) to run as a daemon, since its function is a server , right?

  8. #8
    Linux User netstrider's Avatar
    Join Date
    Jul 2005
    Location
    South Africa
    Posts
    474
    I'm not sure how to get it to run automatically, but if you use KDE or Gnome you can launch it into the background by pressing ALT+F2 and launching it there via command. The output won't be displayed in any terminal window.

  9. #9
    Just Joined!
    Join Date
    Sep 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    6

    Thumbs down Python/Django during boot time.

    Hi netstrider,
    thanks for replying but your tip does not apply. This application will run 24x7. I have to run it during boot time.

    Hi ghostdog74, thanks for replying. I did:

    python manage.py runserver 192.168.0.2:8181 &

    but it still asks for CTRL-C during boot.

    How can I add the command as deamon. Do you have a tutorial or documentation?

    Josir.

  10. #10
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    have you read Django documents...you might be able to find out how to run the server in daemon mode.? have a try

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...