github actions support
This commit is contained in:
parent
c2d1f59dea
commit
3ec2a93310
5 changed files with 136 additions and 46 deletions
|
@ -1,12 +1,38 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Set Tomcat and URL variables
|
||||
set "TOMCAT_VERSION=10.1.9"
|
||||
set "TOMCAT_URL=https://archive.apache.org/dist/tomcat/tomcat-10/v%TOMCAT_VERSION%/bin/apache-tomcat-%TOMCAT_VERSION%-windows-x64.zip"
|
||||
set "WAR_URL=https://github.com/aamitn/URLShortener/releases/download/WAR/shortener.war"
|
||||
set "WAR_URL=https://github.com/aamitn/URLShortener/releases/download/final/shortener.war"
|
||||
set "SQL_FILE_URL=https://github.com/aamitn/URLShortener/raw/master/create.sql"
|
||||
set "SERVER_XML_URL=https://raw.githubusercontent.com/aamitn/URLShortener/master/server.xml"
|
||||
REM Set WildFly and URL variables
|
||||
set "WILDFLY_VERSION=31.0.0.Final"
|
||||
set "WILDFLY_URL=https://github.com/wildfly/wildfly/releases/download/%WILDFLY_VERSION%/wildfly-%WILDFLY_VERSION%.zip"
|
||||
set "WAR_URL=https://github.com/aamitn/URLShortener/releases/download/final/shortener.war"
|
||||
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Ask the user for deployment target
|
||||
echo Choose the deployment target:
|
||||
echo 1. Tomcat
|
||||
echo 2. WildFly
|
||||
set /p DEPLOYMENT_TARGET=Enter the number (default is Tomcat):
|
||||
|
||||
REM Set default deployment target to Tomcat if user input is empty
|
||||
if not defined DEPLOYMENT_TARGET set "DEPLOYMENT_TARGET=1"
|
||||
|
||||
REM Function to download the WAR file
|
||||
:download_war_file
|
||||
echo Downloading shortener.war...
|
||||
curl -LJO "%WAR_URL%"
|
||||
|
||||
REM Function to deploy the WAR file
|
||||
:deploy_war
|
||||
echo Deploying shortener.war to %DEPLOYMENT_TARGET%...
|
||||
if "%DEPLOYMENT_TARGET%"=="1" (
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Function to download and extract Tomcat
|
||||
:download_and_extract_tomcat
|
||||
|
@ -15,10 +41,6 @@ curl -O "%TOMCAT_URL%"
|
|||
PowerShell Expand-Archive "apache-tomcat-%TOMCAT_VERSION%-windows-x64.zip" -DestinationPath .
|
||||
del "apache-tomcat-%TOMCAT_VERSION%-windows-x64.zip"
|
||||
|
||||
REM Function to download the WAR file
|
||||
:download_war_file
|
||||
echo Downloading shortener.war...
|
||||
curl -LJO "%WAR_URL%"
|
||||
|
||||
REM Function to configure Tomcat and deploy the WAR file
|
||||
:configure_and_deploy
|
||||
|
@ -39,64 +61,95 @@ echo Running Tomcat server...
|
|||
cd "apache-tomcat-%TOMCAT_VERSION%\bin"
|
||||
call startup.bat
|
||||
REM Wait for Tomcat to start (adjust sleep time as needed)
|
||||
timeout /t 20 /nobreak
|
||||
timeout /t 30 /nobreak
|
||||
call shutdown.bat
|
||||
timeout /t 2 /nobreak
|
||||
call startup.bat
|
||||
cd ..
|
||||
cd ..
|
||||
|
||||
REM Main Script Execution
|
||||
if "%OS%"=="Windows_NT" (
|
||||
call :download_and_install_mariadb
|
||||
) else if "%DEPLOYMENT_TARGET%"=="2" (
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
|
||||
REM Function to download and extract WildFly
|
||||
:download_and_extract_wildfly
|
||||
echo Downloading WildFly...
|
||||
curl -LJO "%WILDFLY_URL%"
|
||||
PowerShell Expand-Archive "wildfly-%WILDFLY_VERSION%.zip" -DestinationPath .
|
||||
del "wildfly-%WILDFLY_VERSION%.zip"
|
||||
|
||||
|
||||
|
||||
REM Function to deploy the WAR file
|
||||
:deploy_war
|
||||
echo Deploying shortener.war to WildFly...
|
||||
copy shortener.war "wildfly-%WILDFLY_VERSION%\standalone\deployments\"
|
||||
|
||||
REM Run WildFly server
|
||||
:run_wildfly
|
||||
echo Running WildFly...
|
||||
cd "wildfly-%WILDFLY_VERSION%\bin"
|
||||
dir
|
||||
start standalone.bat -c standalone-full.xml
|
||||
|
||||
|
||||
echo WildFly deployment completed successfully!
|
||||
cd..
|
||||
cd..
|
||||
timeout /t 3 /nobreak
|
||||
|
||||
) else (
|
||||
echo Unsupported operating system.
|
||||
echo Invalid deployment target selected.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Local deployment completed successfully!
|
||||
exit /b 0
|
||||
|
||||
echo Deployment Stage 1 Done
|
||||
|
||||
|
||||
REM Function to download and install MariaDB
|
||||
:download_and_install_mariadb
|
||||
echo Downloading MariaDB installer...
|
||||
curl -O "https://mirror.docker.ru/mariadb//mariadb-11.4.0/winx64-packages/mariadb-11.4.0-winx64.zip"
|
||||
REM Check if MariaDB is already installed
|
||||
if not exist mariadb-11.4.0-winx64 (
|
||||
echo Downloading MariaDB installer...
|
||||
curl -O "https://mirrors.aliyun.com/mariadb//mariadb-11.4.0/winx64-packages/mariadb-11.4.0-winx64.zip"
|
||||
|
||||
echo Installing MariaDB...
|
||||
PowerShell Expand-Archive "mariadb-11.4.0-winx64.zip" -DestinationPath .
|
||||
del "mariadb-11.4.0-winx64.zip"
|
||||
echo Installing MariaDB...
|
||||
PowerShell Expand-Archive "mariadb-11.4.0-winx64.zip" -DestinationPath .
|
||||
del "mariadb-11.4.0-winx64.zip"
|
||||
)
|
||||
|
||||
cd mariadb-11.4.0-winx64/bin
|
||||
cd..
|
||||
cd..
|
||||
|
||||
@echo SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234qwer');> dbinit.txt
|
||||
cd..
|
||||
cd..
|
||||
|
||||
REM Get the current directory
|
||||
set "CURRENT_DIR=%CD%"
|
||||
|
||||
REM Create db.bat script for database initialization
|
||||
echo timeout /t 1 /nobreak > db.bat
|
||||
echo cd mariadb-11.4.0-winx64/bin >> db.bat
|
||||
echo mysql -u root -p1234qwer -e "CREATE DATABASE IF NOT EXISTS shortener;" >> db.bat
|
||||
echo curl -LJO "https://github.com/aamitn/URLShortener/raw/master/create.sql" >> db.bat
|
||||
echo mysql -u root -p1234qwer ^< create.sql >> db.bat
|
||||
echo mysql -u root -p1234qwer -e "SHOW DATABASES;" >> db.bat
|
||||
echo mysql -u root -p1234qwer -e "USE shortener" >> db.bat
|
||||
echo mysql -u root -p1234qwer -e "SELECT * FROM shortener;" >> db.bat
|
||||
echo del create.sql >> db.bat
|
||||
echo echo Deployed Successfully... >> db.bat
|
||||
echo start "" http://localhost:8080 >> db.bat
|
||||
echo exit /b 0 >> db.bat
|
||||
|
||||
REM Start the db.bat script
|
||||
start db.bat
|
||||
|
||||
REM Navigate to mariadb-11.4.0-winx64/bin
|
||||
cd mariadb-11.4.0-winx64/bin
|
||||
|
||||
REM Get the current directory
|
||||
set "CURRENT_DIR=%CD%"
|
||||
|
||||
REM Initialize DB
|
||||
call mariadb-install-db.exe
|
||||
|
||||
REM Run MariaDB server with the init file
|
||||
call mysqld.exe --console --init-file="%CURRENT_DIR%\\dbinit.txt"
|
||||
start mysqld.exe --console --init-file="%CURRENT_DIR%\\dbinit.txt"
|
||||
|
||||
REM Create DB
|
||||
timeout /t 1 /nobreak
|
||||
mysql -u root -p1234qwer -e "CREATE DATABASE IF NOT EXISTS shortener;"
|
||||
curl -LJO "https://github.com/aamitn/URLShortener/raw/master/create.sql"
|
||||
mysql -u root -p1234qwer < create.sql
|
||||
mysql -u root -p1234qwer -e "SHOW ENGINE PERFORMANCE_SCHEMA STATUS;SHOW ENGINE INNODB STATUS;"
|
||||
mysql -u root -p1234qwer -e "SHOW DATABASES;"
|
||||
mysql -u root -p1234qwer -e "USE shortener; SHOW TABLES; SHOW TABLE STATUS\G;"
|
||||
del create.sql
|
||||
|
||||
REM start browser
|
||||
echo Application Deployed Successfully...
|
||||
start "" http://localhost:8080
|
||||
timeout /t 20 /nobreak
|
||||
exit /b
|
||||
|
|
14
pom.xml
14
pom.xml
|
@ -59,15 +59,21 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- log4j2 equivalent dependency : spring-boot-starter-logging-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Starter without logging dependency-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -86,7 +92,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<version>24.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
16
src/main/resources/log4j2.xml
Normal file
16
src/main/resources/log4j2.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<File name="File" fileName="logs/shortener.log">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</File>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
10
src/main/webapp/WEB-INF/jboss-deployment-structure.xml
Normal file
10
src/main/webapp/WEB-INF/jboss-deployment-structure.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-deployment-structure>
|
||||
<deployment>
|
||||
<!-- Exclude the JBoss Logger subsystem -->
|
||||
<exclude-subsystems>
|
||||
<subsystem name="logging" />
|
||||
</exclude-subsystems>
|
||||
|
||||
</deployment>
|
||||
</jboss-deployment-structure>
|
5
src/main/webapp/WEB-INF/jboss-web.xml
Normal file
5
src/main/webapp/WEB-INF/jboss-web.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/</context-root>
|
||||
<virtual-host>default-host</virtual-host> <!-- does mapping to host inside server -->
|
||||
</jboss-web>
|
Loading…
Reference in a new issue