How to restart Glassfish with a commandline command

5k views Asked by At

I would like to achieve the same restart effect as clicking on the Restart button of the glassfish admin web gui (Server->General->Restart) on picture. But I would like to do it via command line

enter image description here

I have some strange behaviour of the app during undeploy. If I restart the server via GUI ant then do the : asadmin deploy asadmin undeploy

the app undeploys in a few seconds

But If I have the GF server as a windows service and do a restart of the service and after that : asadmin deploy asadmin undeploy

the app undeploys in 5 minutes.

So I would like to find the equivalent asadmin command for server restart as via web GUI.

I have already tried:

asadmin restart-domain --force=false domain1
asadmin restart-domain --force=true domain1
asadmin stop-domain domain1
asadmin start-domain domain1

but no luck

2

There are 2 answers

0
sirolf2009 On

Here's the script we use:

echo "Stopping the server"
INSTANCES=`asadmin list-instances | grep -v "Command" | cut -d' ' -f1`
for INSTANCE in $INSTANCES; do
    asadmin stop-instance $INSTANCE
done
asadmin stop-domain $DOMAIN

echo "Starting the server"
asadmin start-domain
INSTANCES=`asadmin list-instances | grep -v "Command" | cut -d' ' -f1`
for INSTANCE in $INSTANCES; do
    asadmin start-instance $INSTANCE
done
1
Fábio Barros de Almeida On
taskkill /F /IM java.exe
asadmin start-domain domain1