Deploying with Capistrano via cron

I’m attempting to auto deploy a rails application to a development
server periodically during ongoing development. I’ve setup ssh keys
to allow the proper user auto login permissions, but have ran into 2
issues.

  1. When the script is run from a cron job as the same user as I
    currently manually deploy from I receive an error when reaper tries to
    execute - “can’t get terminal parameters (Inappropriate ioctl for
    device)”. I’m assuming that the reaper script is trying to capture
    the PIDs to restart on the remote server and cannot since there is no
    terminal running. Is there way give a virtual terminal to be used?
    This maybe just Linux related question -but thought I’d start on the
    rails list.

  2. Periodically when the “sudo reaper” portion runs during deployment,
    a password prompt will display and the password will need to be
    entered. What causes the password prompt -according the docs the sudo
    commands will use the same credentials in the auto login or previously
    entered when the rake deploy command first starts.

Michael E. wrote:

I’m attempting to auto deploy a rails application to a development
server periodically during ongoing development. I’ve setup ssh keys
to allow the proper user auto login permissions, but have ran into 2
issues.

  1. Periodically when the “sudo reaper” portion runs during deployment,
    a password prompt will display and the password will need to be
    entered. What causes the password prompt -according the docs the sudo
    commands will use the same credentials in the auto login or previously
    entered when the rake deploy command first starts.

What do you mean “periodically?” Every time, or more than once per
deploy?

Assuming you mean every time, your answer is in what you wrote. You are
using ssh keys to allow for auto login, but sudo as configured on your
remote hosts requires your password.

Ray

On 4/6/06, Michael E. [email protected] wrote:

I’m attempting to auto deploy a rails application to a development
server periodically during ongoing development. I’ve setup ssh keys
to allow the proper user auto login permissions, but have ran into 2
issues.

I have completely different setup for this which might interest you.
I’m using svn hooks with a cron script to auto export on EVERY commit.
It does a lot of other things as well - backup, email notification,
reload of the DB structure, reload of fixtures. This way I have a
deployed app on every change. It’s very easy to do with svn hooks and
some ruby/bash scripts.

  1. When the script is run from a cron job as the same user as I
    currently manually deploy from I receive an error when reaper tries to
    execute - “can’t get terminal parameters (Inappropriate ioctl for
    device)”. I’m assuming that the reaper script is trying to capture
    the PIDs to restart on the remote server and cannot since there is no
    terminal running. Is there way give a virtual terminal to be used?
    This maybe just Linux related question -but thought I’d start on the
    rails list.

You can run sudo with -l which gives sudo a login shell to work in. I
find it’s usually better this way, as I can also set environment vars
in the ~/.bash_profile to set things like the rails environment. See
if that also solves your problem.

If you are running a system with SELinux active, there are even more
complications, so be careful with that.

  1. Periodically when the “sudo reaper” portion runs during deployment,
    a password prompt will display and the password will need to be
    entered. What causes the password prompt -according the docs the sudo
    commands will use the same credentials in the auto login or previously
    entered when the rake deploy command first starts.

That’s actually settable in your sudoers file. You can let it run
passwordless if you want (but then limit the commands to be
executed!), or you can set a timeout for the password, so that it’ll
ask for it the first time only, and remember it for the duration of
the timeout. If you give something like 3-5 minutes of timeout, you
should be able to easily deploy with only one password entry.

I have in my blog some info about using sudo for rails deployment:
FamUndo.com is for sale | HugeDomains.
And I can give you some help in fine tuning it for your environment.

Bye,

Guy.


Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com

Hi,
I have added a rake file in my rails application that executes cap
deploy for my application on a button click. When I run this command
directed from my application folder it deploys correctly.
But running cap deploy as rake tasks gives me following error

executing `deploy:update_code’
updating the cached checkout on all servers
executing locally: "git ls-remote —
command finished in 10805ms

  • executing “if— fi”
    servers:
    stty: standard input: Inappropriate ioctl for device
    stty: standard input: Inappropriate ioctl for device
    stty: standard input: Inappropriate ioctl for device
    *** [deploy:update_code] rolling back

Any help on this will be highly appreciated
Thanks,

Michael E. wrote in post #59877:

I’m attempting to auto deploy a rails application to a development
server periodically during ongoing development. I’ve setup ssh keys
to allow the proper user auto login permissions, but have ran into 2
issues.

  1. When the script is run from a cron job as the same user as I
    currently manually deploy from I receive an error when reaper tries to
    execute - “can’t get terminal parameters (Inappropriate ioctl for
    device)”. I’m assuming that the reaper script is trying to capture
    the PIDs to restart on the remote server and cannot since there is no
    terminal running. Is there way give a virtual terminal to be used?
    This maybe just Linux related question -but thought I’d start on the
    rails list.

  2. Periodically when the “sudo reaper” portion runs during deployment,
    a password prompt will display and the password will need to be
    entered. What causes the password prompt -according the docs the sudo
    commands will use the same credentials in the auto login or previously
    entered when the rake deploy command first starts.