From Glassfish to Wildfly - Autodeploy directory - part 2

In glassfish you have /autodeploy directory where to put ear, war and jar in order to auto deploy it in application server.

In Wildfly there is also autodeploy dir.. /opt/wildfly/standalone/deployments/

When you put an application in the directory deployment scanner start and deploy automatically the application.

I notice that deployment scanner stop to works when a large file is upload to server.
The deployment scanner see incomplete file and wait for completition.. but in 8.1 wildfly it stops and deployment scanner stop to works until next restart.

In order to avoid this problem

Make other directory for uploading
Put in crontab(i.e. every 2 minute) the following script

#!/bin/bash
WILDFLY_DEPLOY_DIR="/opt/wildfly/standalone/deployments/"
AUTODEPLOY_DIR="/home/myftp/autodeploy/"
#touch "$AUTODEPLOY_DIR"avoid_empty_dir_error
for filename in $AUTODEPLOY_DIR*.*ar; do
#for filename in 'find /home/myftp/autodeploy -name "*.*ar"'; do
if [ "$filename" = "$AUTODEPLOY_DIR*.*ar" ]; then
echo "nofiles"
else
       fuser1=$(/sbin/fuser "$filename")
       if [[ -z "${fuser1}" ]];
       then
               echo "move and rename the file"
                #file non usato da nessun processo, copia terminata
               /bin/cp $filename $WILDFLY_DEPLOY_DIR #uso bin/cp in modo da non chiedere overwrite
               mv $filename $filename.bak
       else echo "copia ftp in corso" #copia in corso
       fi
fi
done

that copy the *.ar file from autodeploy dir to wildfly real autodeploy dir only when the file transfer is complete!

No comments: