[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re(2): [Fab-user] SSH abort Timeout
From: |
Miguel A. Lamy |
Subject: |
Re(2): [Fab-user] SSH abort Timeout |
Date: |
Thu, 10 Sep 2009 15:42:33 +0100 |
Hi Jeff,
Thanks for replying.
I am still working on my fabfile so it's a bit messy.
I extracted the relevant code I hope it helps ( all ip address are forged
except 193.137.94.166 ):
from __future__ import with_statement
from fabric.api import local, hosts, env, prompt, roles, run, settings, abort
from fabric.contrib.project import rsync_project
env.roledefs['winservers'] = ['address@hidden', 'address@hidden:23',
'address@hidden', 'address@hidden', 'address@hidden', 'address@hidden' ]
env.roledefs['linuxservers'] = ['address@hidden', 'address@hidden',
'address@hidden']
@roles('winservers', 'linuxservers')
def get_env_vars():
"""
get env var from parameter file
"""
with settings(warn_only=True):
if env.host_string in env.roledefs['winservers']:
env.HOST_OS='win'
else:
env.HOST_OS='linux'
env.paramf='/opt/tools/server_params/clientes/server_param_%s' %
env.HOST_OS
env.JBOSS_HOME=local('cat %s|grep "JBOSS_HOME" |cut -d= -f2' % env.paramf)
env.SIAG_HOME=local('cat %s|grep "SIAG_HOME" |cut -d= -f2' % env.paramf)
env.SERVICE_NAME=local('cat %s|grep "SERVICE_NAME" |cut -d= -f2' %
env.paramf)
env.JCONF=local('cat %s|grep "JCONF" |cut -d= -f2' % env.paramf)
env.RMI_PORT=local('cat %s|grep "RMI_PORT" |cut -d= -f2' % env.paramf)
env.CONFIG=local('cat %s|grep "CONFIG" |cut -d= -f2' % env.paramf)
env.APP_SERVER='JBOSS'
@roles('winservers', 'linuxservers')
def stop_siag():
"""
stop AS
"""
with settings(warn_only=True):
# get_env_vars()
# get_env_vars() must be called before this task
result = run('/opt/tools/testvarAS.sh -f %s' % env.paramf , shell=False)
if result.failed:
# should write failure to file and mail it to me
else:
run('rm -rf %s/tmp && rm -rf %s/work' % (env.JBOSS_PATH, env.JBOSS_PATH))
Since my knowledge about python is "no knowledge" I wrote a small shell script
that stop AS servers for me
the way I want (I extracted only a bit of code from that script to clarify):
#!/bin/bash
OPTIND=1
while getopts "f:v:j" optname
do
case "$optname" in
"f")
HOST_OS=$(grep "HOST_OS" $OPTARG|cut -d= -f2)
JBOSS_HOME=$(grep "JBOSS_HOME" $OPTARG|cut -d= -f2)
SIAG_HOME=$(grep "SIAG_HOME" $OPTARG|cut -d= -f2)
SERVICE_NAME=$(grep "SERVICE_NAME" $OPTARG|cut -d= -f2)
RMI_PORT=$(grep "RMI_PORT" $OPTARG|cut -d= -f2)
JAVA_HOME=$(grep "JAVA_HOME" $OPTARG|cut -d= -f2)
APP_SERVER=$(grep "APP_SERVER" $OPTARG|cut -d= -f2)
#echo $HOST_OS
#echo $JBOSS_HOME
#echo $SERVICE_NAME
;;
"v")
HOST_OS=$(echo $OPTARG|cut '-d ' -f1)
JBOSS_HOME=$(echo $OPTARG|cut '-d ' -f2)
SERVICE_NAME=$(echo $OPTARG|cut '-d ' -f3)
APP_SERVER=$(echo $OPTARG|cut '-d ' -f4)
echo $HOST_OS
echo $JBOSS_HOME
echo $SERVICE_NAME
echo $APP_SERVER
;;
"j")
WITH_JNDI="Y"
#echo $optname
;;
"?")
echo "Opção $OPTARG"
;;
":")
echo "Opção $OPTARG sem argumentos"
;;
*)
# Should not occur
echo "Erro desconhecido a processar opções"
;;
esac
done
### Paragem do JBOSS
if [ "$APP_SERVER" = "" ]; then
APP_SERVER="JBOSS"
fi
echo "A terminar..."$APP_SERVER
if [ "$HOST_OS" = "linux" ]; then
echo "Plataforma Linux"
else
echo "Plataforma Windows"
fi
Fab should not abort executing stopAS task when reachs the ip address
193.137.94.166.
I hope this is the output you need:
[localhost] run: cat /opt/tools/server_params/clientes/server_param_win|grep
"CONFIG" |cut -d= -f2
address@hidden run: /opt/tools/testvarAS.sh -f
/opt/tools/server_params/clientes/server_param_win
Fatal error: Timed out trying to connect to 193.137.94.166
Aborting.
Just one more question...
When I started looking at Fabric I thought that I didn't to explicitly put the
shell scripts I want to
execute to do deploy in the remote hosts (in this example testvarAS.sh). I
thought that I only need to have
it locally and run it with Fabric. I was totally wrong wasn't I ? I hope my
question don't seems to stupid.
Thanks,
Miguel Lamy
address@hidden on quinta-feira, 10 de Setembro de 2009 at 13:52 wrote:
:Hi Miguel,
:
:You're correct, there's currently no "nice" support for timeouts like
:that. However, the issue has come up before and there's a ticket for
:it:
:
: http://code.fabfile.org/issues/show/8
:
:I've just updated the ticket's description to deal with your specific
:situation -- earlier folks wanted a configurable timeout; you raise
:the point that we need to make it possible to skip servers that *do*
:timeout.
:
:I also raised its priority now that there's more than one person
:concerned about the problem :)
:
:Finally, if you could send me an example of your fabfile and the
:output when you run your timing-out task, I'd like to make sure I am
:reading you correctly -- there's a small chance that things can work
:the way you want them to without further edits to Fabric itself (e.g.
:you may be using warn_only incorrectly, or there may be a bug in it.)
:
:Thanks,
:Jeff
:
:On Thu, Sep 10, 2009 at 5:11 AM, Miguel A. Lamy <address@hidden> wrote:
:> Hello all,
:>
:> I just began using Fabric and my knowledge is still very limited.
Nevertheless I am trying to follow the
:docs
:> and the mail list and I was able to solve some of the problems I had.
:>
:> Unfornately there is any issue that I can't figure out the solution. I have
host list of about 15 servers
:> that I use to do the deploys. Sometimes in some of the servers that I want
to deploy I can't connect with
:ssh
:> because of network problems in that servers. Right now fabric is aborting
after a ssh timeout. What I want
:is
:> logging that failure and still deploy to the other servers in host list.
:>
:> I tried with settings(warn_only=True): but with no luck. Can you help me ?
:>
:> Does control abortion in the rsync_project for the same reasons resolved
the same way ?
:>
:> Note: I use Fabric 0.9b1
:>
:> Kind regards,
:>
:> Miguel Lamy
:>
:>
:>
:>
:> _______________________________________________
:> Fab-user mailing list
:> address@hidden
:> http://lists.nongnu.org/mailman/listinfo/fab-user
:>
: