Moved pwrd to pandorafms
This commit is contained in:
parent
40dcf343d6
commit
c51226e3de
|
@ -0,0 +1,14 @@
|
||||||
|
instalar java
|
||||||
|
instalar selenium (descargar)
|
||||||
|
instalar xorg-x11-server-Xvfb
|
||||||
|
#wget ftp://rpmfind.net/linux/centos/6.6/os/x86_64/Packages/xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm
|
||||||
|
#yum install xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm
|
||||||
|
#Xvfb :99 -ac &
|
||||||
|
---> Pulsar Enter para continuar
|
||||||
|
#export DISPLAY=:99
|
||||||
|
#java -jar seleniumXXX.jar
|
||||||
|
|
||||||
|
Ya tenemos funcionando Selenium sin necesidad de X.
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,80 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$1" == "" ] || [ "$1" != "--install" ]; then
|
||||||
|
cat<<_HELP
|
||||||
|
**********************
|
||||||
|
PWR Server installer
|
||||||
|
**********************
|
||||||
|
|
||||||
|
To install the Pandora web robot daemon (pwrd)
|
||||||
|
Please launch this script as root:
|
||||||
|
|
||||||
|
$0 --install
|
||||||
|
|
||||||
|
|
||||||
|
_HELP
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "`rpm -qa | grep xorg-x11-server-Xvfb | wc -l`" == "0" ]; then
|
||||||
|
echo "Package xorg-x11-server-Xvfb is required"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x pwrd
|
||||||
|
|
||||||
|
PWR_SERVER_DEST=/usr/lib/pwr
|
||||||
|
PWR_SERVER_RSC=/etc/pwr/tmp
|
||||||
|
PWR_SERVER_LOG=/var/log/pwr
|
||||||
|
PWR_FIREFOX_INSTALLDIR=/opt
|
||||||
|
|
||||||
|
mkdir -p $PWR_SERVER_DEST
|
||||||
|
mkdir -p $PWR_SERVER_LOG
|
||||||
|
mkdir -p $PWR_SERVER_RSC
|
||||||
|
mkdir -p $PWR_FIREFOX_INSTALLDIR
|
||||||
|
|
||||||
|
|
||||||
|
tar xvf firefox-43.0.tar >/dev/null
|
||||||
|
mv firefox $PWR_FIREFOX_INSTALLDIR/
|
||||||
|
|
||||||
|
tar xvzf firefox_profile.tar.gz >/dev/null
|
||||||
|
chown -R `whoami`. firefox_profile
|
||||||
|
mv firefox_profile $PWR_FIREFOX_INSTALLDIR
|
||||||
|
|
||||||
|
ln -s $PWR_FIREFOX_INSTALLDIR/firefox/firefox /usr/bin/firefox
|
||||||
|
|
||||||
|
# Generate logrotate configuration
|
||||||
|
|
||||||
|
echo <<EO_LROTATE > /etc/logrotate.d/pwrd
|
||||||
|
/var/log/pwr/pwr_std.log
|
||||||
|
/var/log/pwr/pwr_error.log {
|
||||||
|
weekly
|
||||||
|
missingok
|
||||||
|
size 300000
|
||||||
|
rotate 3
|
||||||
|
maxage 90
|
||||||
|
compress
|
||||||
|
notifempty
|
||||||
|
copytruncate
|
||||||
|
}
|
||||||
|
|
||||||
|
EO_LROTATE
|
||||||
|
|
||||||
|
cp ./selenium-server-standalone-2.53.1.jar $PWR_SERVER_DEST/
|
||||||
|
cp ./pwrd /etc/init.d/pwrd
|
||||||
|
chmod +x /etc/init.d/pwrd
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
*********************
|
||||||
|
PWR Server deployed
|
||||||
|
*********************
|
||||||
|
|
||||||
|
Succesfully installed!
|
||||||
|
|
||||||
|
Please start the service with:
|
||||||
|
|
||||||
|
/etc/init.d/pwrd start
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
|
@ -0,0 +1,325 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# pwr - this script starts and stops the pwr grid
|
||||||
|
#
|
||||||
|
# chkconfig: - 85 1# description: PWRD Grid is a distributed testing platform for browser-based automation.
|
||||||
|
# processname: pwr
|
||||||
|
# pidfile: $base_dir/pwr.pid
|
||||||
|
|
||||||
|
# Source function library.
|
||||||
|
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
. /etc/rc.d/init.d/functions
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
pwr_dir=/usr/lib/pwr
|
||||||
|
log_dir=/var/log/pwr
|
||||||
|
std_log=$log_dir/pwr_std.log
|
||||||
|
base_dir=/etc/pwr/tmp
|
||||||
|
java=/usr/bin/java
|
||||||
|
pwr="$pwr_dir/selenium-server-standalone-2.53.1.jar"
|
||||||
|
# Following parameters will control node capabilities: -browser browserName=firefox,maxInstances=1,platform=LINUX
|
||||||
|
PWROPTS=" -firefoxProfileTemplate /opt/firefox_profile"
|
||||||
|
PWR_HUB_OPTS=""
|
||||||
|
user=root
|
||||||
|
xvfb_pid_file=$base_dir/xvfb.pid
|
||||||
|
|
||||||
|
# Variable
|
||||||
|
host=`ip a show $(route -n | awk '/^0\.0\.0\.0/ {print $NF}') | grep "inet " | awk '{print $2}' | cut -f1 -d'/' | head -1`
|
||||||
|
|
||||||
|
# Start Xvfb, required for firefox in server without X
|
||||||
|
function start_xvfb() {
|
||||||
|
`which Xvfb >/dev/null 2>&1`
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Xvfb not found, please install it"
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
echo 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
Xvfb :99 -ac > /dev/null 2>&1 &
|
||||||
|
export DISPLAY=:99
|
||||||
|
ps -eo pid,cmd | grep Xvfb | grep -v grep | awk {'print $1 '} > $xvfb_pid_file
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop Xvfb
|
||||||
|
function stop_xvfb() {
|
||||||
|
if test -f $xvfb_pid_file ; then
|
||||||
|
# Check if there's more instances of pwrd running i.e. standalone + node
|
||||||
|
if [ ! -e "$base_dir/pwrd_node.pid" ] && [ ! -e "$base_dir/pwrd.pid" ]; then
|
||||||
|
echo -n "Stopping Xvfb..."
|
||||||
|
PID=$(cat $xvfb_pid_file)
|
||||||
|
if [ `kill -9 $PID 2>&1 | grep "No such process" | wc -l` == "1" ]; then
|
||||||
|
# PID file exists but no process
|
||||||
|
test -f $xvfb_pid_file && rm -f $xvfb_pid_file
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "(1) pwrd process left. Skipping Xvfb"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# START
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Start Selenium Standalone server
|
||||||
|
function start() {
|
||||||
|
if test -f $pid_file
|
||||||
|
then
|
||||||
|
PID=`cat $pid_file`
|
||||||
|
if ps --pid $PID >/dev/null; then
|
||||||
|
echo "PWRD is already running: $PID"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
echo "Removing stale pid file: $pid_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "`start_xvfb`" != "0" ]; then
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed... Check Xvfb"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Starting PWRD..."
|
||||||
|
|
||||||
|
export DISPLAY=:99
|
||||||
|
su $user -c "$java -jar $pwr -host $host $PWROPTS > $std_log 2>&1 &"
|
||||||
|
|
||||||
|
if [ $? == "0" ]; then
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
echo "Success"
|
||||||
|
else
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Store PID
|
||||||
|
ps -eo pid,cmd | grep $pwr | grep -v "node" | grep -v "hub" | grep -v grep | awk {'print $1 '} > $pid_file
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start Selenium GRID server: HUB component
|
||||||
|
function start-hub() {
|
||||||
|
if test -f $pid_file
|
||||||
|
then
|
||||||
|
PID=`cat $pid_file`
|
||||||
|
if ps --pid $PID >/dev/null; then
|
||||||
|
echo "PWRD is already running: $PID"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
echo "Removing stale pid file: $pid_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo -n "Starting PWRD..."
|
||||||
|
|
||||||
|
# No Xvfb needed in hub mode
|
||||||
|
|
||||||
|
su $user -c "$java -jar $pwr -host $host -role hub $PWR_HUB_OPTS > $std_log 2>&1 &"
|
||||||
|
|
||||||
|
if [ $? == "0" ]; then
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
echo "Success"
|
||||||
|
else
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Store PID
|
||||||
|
ps -eo pid,cmd | grep $pwr | grep "hub" | grep -v grep | awk {'print $1 '} > $pid_file
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start Selenium GRID server: Node Connect to hub
|
||||||
|
function start-node() {
|
||||||
|
if test -f $pid_file
|
||||||
|
then
|
||||||
|
PID=`cat $pid_file`
|
||||||
|
if ps --pid $PID >/dev/null; then
|
||||||
|
echo "PWRD is already running: $PID"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
echo "Removing stale pid file: $pid_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "`start_xvfb`" != "0" ]; then
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed... Check Xvfb"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Starting PWRD..."
|
||||||
|
|
||||||
|
export DISPLAY=:99
|
||||||
|
su $user -c "$java -jar $pwr -host $host -role node -hub $1 $PWROPTS > $std_log 2>&1 &"
|
||||||
|
|
||||||
|
if [ $? == "0" ]; then
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
echo "Success"
|
||||||
|
else
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Store PID
|
||||||
|
ps -C java -eo pid,cmd | grep $pwr | grep "node" | grep -v grep | awk {'print $1 '} > $pid_file
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# STOP
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Stop Selenium Standalone server
|
||||||
|
function stop() {
|
||||||
|
if test -f $pid_file ; then
|
||||||
|
echo -n "Stopping PWRD..."
|
||||||
|
PID=$(cat $pid_file)
|
||||||
|
su $user -c "kill -3 $PID"
|
||||||
|
kill -9 $PID >/dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
sleep 5
|
||||||
|
test -f $pid_file && rm -f $pid_file
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "PWRD could not be stopped..."
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
failure
|
||||||
|
fi
|
||||||
|
echo "Failed"
|
||||||
|
fi
|
||||||
|
stop_xvfb
|
||||||
|
else
|
||||||
|
echo "PWRD is not running."
|
||||||
|
stop_xvfb
|
||||||
|
if [ -e /etc/rc.d/init.d/functions ]; then
|
||||||
|
success
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# STATUS
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Status of Selenium Standalone server
|
||||||
|
function status() {
|
||||||
|
if test -f $pid_file ; then
|
||||||
|
PID=`cat $pid_file`
|
||||||
|
if ps --pid $PID >/dev/null ; then
|
||||||
|
echo "PWRD is running: $PID"
|
||||||
|
if test -f $xvfb_pid_file ; then
|
||||||
|
PID=`cat $xvfb_pid_file`
|
||||||
|
if test -f $xvfb_pid_file ; then
|
||||||
|
echo "Xvfb is running: $PID"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "PWRD isn't running..."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "PWRD isn't running..."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start) # Standalone
|
||||||
|
pid_file=$base_dir/pwrd.pid
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
start-hub) # hub
|
||||||
|
pid_file=$base_dir/pwrd_hub.pid
|
||||||
|
start-hub
|
||||||
|
;;
|
||||||
|
start-node) # node
|
||||||
|
pid_file=$base_dir/pwrd_node.pid
|
||||||
|
start-node $2
|
||||||
|
;;
|
||||||
|
stop) # standalone
|
||||||
|
pid_file=$base_dir/pwrd.pid
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
stop-hub) # hub
|
||||||
|
pid_file=$base_dir/pwrd_hub.pid
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
stop-node) # node
|
||||||
|
pid_file=$base_dir/pwrd_node.pid
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart) # standalone
|
||||||
|
pid_file=$base_dir/pwrd.pid
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
restart-hub) # hub
|
||||||
|
pid_file=$base_dir/pwrd_hub.pid
|
||||||
|
stop
|
||||||
|
start-hub
|
||||||
|
;;
|
||||||
|
restart-node) # node
|
||||||
|
pid_file=$base_dir/pwrd_node.pid
|
||||||
|
stop
|
||||||
|
start-node $2
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
pid_file=$base_dir/pwrd.pid
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
status-hub) # hub
|
||||||
|
pid_file=$base_dir/pwrd_hub.pid
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
status-node) # node
|
||||||
|
pid_file=$base_dir/pwrd_node.pid
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $SELF start*|stop*|restart*|status*"
|
||||||
|
echo " start* (standalone, hub or node)"
|
||||||
|
echo " start"
|
||||||
|
echo " start-hub"
|
||||||
|
echo " start-node http://hub:4444/grid/register"
|
||||||
|
echo " stop* (standalone, hub or node)"
|
||||||
|
echo " stop"
|
||||||
|
echo " stop-hub"
|
||||||
|
echo " stop-node"
|
||||||
|
echo " restart* (standalone, hub or node)"
|
||||||
|
echo " restart"
|
||||||
|
echo " restart-hub"
|
||||||
|
echo " restart-node http://hub:4444/grid/register"
|
||||||
|
echo " status* (standalone, hub or node)"
|
||||||
|
echo " status"
|
||||||
|
echo " status-hub"
|
||||||
|
echo " status-node"
|
||||||
|
exit 9
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo FIN [$1]
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue