Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an easy way to prepare and shutdown server locally #195

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ Domain hc dc (on master)
/host=master:reload
```

### Alternative Setup
* Has removed security realm
* Using `source` to set `JBOSS_HOME` from SERVER_ZIP

Standalone
```
source ./prepare.sh <SERVER_ZIP> standalone
```
Domain
```
source ./prepare.sh <SERVER_ZIP> domain
```
Domain hc dc (on master)
```
source ./prepare.sh <SERVER_ZIP> domain-hc-dc
```
#### To stop server started by `prepare.sh`
Standalone
```
./shutdown.sh <SERVER_ZIP> standalone
```
Domain
```
./shutdown.sh <SERVER_ZIP> domain
```
Domain hc dc (on master)
```
./shutdown.sh <SERVER_ZIP> domain-hc-dc
```

### Run all tests:

To run the tests you need to set the ``JBOSS_HOME`` property pointing to the WildFly directory. If have run the ``start-wildfly`` script, you can see the WildFly directory printed out in the console.
Expand Down
54 changes: 54 additions & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

SERVER_ZIP=$1
MODE=$2

# Check if unzip is successful
if unzip -q "${SERVER_ZIP}"; then
echo "Server unzip successful"
else
echo "Error: Failed to unzip ${SERVER_ZIP}"
exit 1
fi

# Locate server directory
SERVER_DIR="$(jar tf ${SERVER_ZIP} | head -1 | cut -d '/' -f 1)"
echo "Server directory: $SERVER_DIR"

# Set JBOSS_HOME
export JBOSS_HOME=$SERVER_DIR

# Check if the server has "master" or "primary" configuration
if find $SERVER_DIR -name "host-primary.xml" -print -quit | grep -q .; then
HOST="primary"
HOST_CONFIG_FILE="host-primary.xml"
else
HOST="master"
HOST_CONFIG_FILE="host-master.xml"
fi
echo "Host: $HOST"
echo "Host configuration file: $HOST_CONFIG_FILE"

if [ "$MODE" == "domain" ]; then
$SERVER_DIR/bin/domain.sh --host-config=$HOST_CONFIG_FILE &
$SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST/core-service=management/management-interface=http-interface
:undefine-attribute(name=security-realm)
:reload"
sleep 40
elif [ "$MODE" == "domain-hc-dc" ]; then
# Setup dc, please setup hc manually
cp -r $SERVER_DIR/domain/ $SERVER_DIR/dc/
$SERVER_DIR/bin/domain.sh --host-config=$HOST_CONFIG_FILE -Djboss.domain.base.dir=$SERVER_DIR/dc &
$SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST/core-service=management/management-interface=http-interface
:undefine-attribute(name=security-realm)
/host=$HOST:reload"
sleep 40
elif [ "$MODE" == "standalone" ]; then
$SERVER_DIR/bin/standalone.sh -c standalone-full-ha.xml &
$SERVER_DIR/bin/jboss-cli.sh -c "/core-service=management/management-interface=http-interface
:undefine-attribute(name=security-realm)
:reload"
sleep 40
else
echo "Error: Unknown mode. Specify either domain, domain-hc-dc or standalone"
fi
26 changes: 26 additions & 0 deletions shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

SERVER_ZIP=$1
MODE=$2

# Locate server directory
SERVER_DIR="$(jar tf ${SERVER_ZIP} | head -1 | cut -d '/' -f 1)"

# Check if the server has "master" or "primary" configuration
if find $SERVER_DIR -name "host-primary.xml" -print -quit | grep -q .; then
HOST="primary"
else
HOST="master"
fi

if [ "$MODE" == "domain" ]; then
$SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST:shutdown"
elif [ "$MODE" == "domain-hc-dc" ]; then
$SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST:shutdown"
# Clean dc, please clean hc manually
rm -r -d $SERVER_DIR/dc/*
elif [ "$MODE" == "standalone" ]; then
$SERVER_DIR/bin/jboss-cli.sh -c ":shutdown"
else
echo "Error: Unknown mode. Specify either domain, domain-hc-dc or standalone"
fi