Gestione status jboss
This commit is contained in:
parent
b2189e2450
commit
791cc9f524
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
}
|
@ -12,7 +12,7 @@ $originalDirectory = Get-Location
|
||||
|
||||
# Function to check if JBoss is running
|
||||
function Is-JBossRunning {
|
||||
$jbossProcess = Get-Process -Name "java" -ErrorAction SilentlyContinue |
|
||||
$jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" |
|
||||
Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" }
|
||||
return $null -ne $jbossProcess
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ $JAVA_HOME = "C:\Dev2012\BUILDERS\java\jdk1.8.0_291"
|
||||
|
||||
# Function to check if JBoss is already running
|
||||
function Is-JBossRunning {
|
||||
$jbossProcess = Get-Process -Name "java" -ErrorAction SilentlyContinue |
|
||||
$jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" |
|
||||
Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" }
|
||||
return $null -ne $jbossProcess
|
||||
}
|
||||
@ -24,7 +24,7 @@ if (-not (Test-Path $JBOSS_HOME)) {
|
||||
}
|
||||
|
||||
# Check if configuration file exists
|
||||
$configFile = "$JBOSS_HOME\standalone\configuration\standalone-ADVC-full.xml"
|
||||
$configFile = "$JBOSS_HOME\standalone\configuration\standalone-ADVCsvil-full.xml"
|
||||
if (-not (Test-Path $configFile)) {
|
||||
Write-Host "Error: Configuration file not found at $configFile" -ForegroundColor Red
|
||||
exit 1
|
||||
@ -35,7 +35,8 @@ $env:JAVA_HOME = $JAVA_HOME
|
||||
$env:JBOSS_HOME = $JBOSS_HOME
|
||||
$env:PATH = "$JAVA_HOME\bin;$env:PATH"
|
||||
$env:NOPAUSE = "true"
|
||||
$env:LAUNCH_JBOSS_IN_BACKGROUND = "true"
|
||||
# Remove this as it might affect logging
|
||||
# $env:LAUNCH_JBOSS_IN_BACKGROUND = "true"
|
||||
|
||||
# Check if JBoss is already running
|
||||
if (Is-JBossRunning) {
|
||||
@ -46,7 +47,7 @@ if (Is-JBossRunning) {
|
||||
Write-Host "Starting JBoss EAP 7.4..." -ForegroundColor Green
|
||||
Write-Host "Using Java from: $JAVA_HOME" -ForegroundColor Yellow
|
||||
Write-Host "JBoss Home: $JBOSS_HOME" -ForegroundColor Yellow
|
||||
Write-Host "Using configuration: standalone-ADVC-full.xml" -ForegroundColor Yellow
|
||||
Write-Host "Using configuration: standalone-ADVCsvil-full.xml" -ForegroundColor Yellow
|
||||
|
||||
# Start JBoss in standalone mode
|
||||
$startScript = "$JBOSS_HOME\bin\standalone.bat"
|
||||
@ -70,10 +71,22 @@ Write-Host "JVM Options: $env:JAVA_OPTS" -ForegroundColor Yellow
|
||||
Write-Host "Remote debugging enabled on port 8787" -ForegroundColor Cyan
|
||||
|
||||
# Create the command line arguments
|
||||
$cmdArgs = "-c standalone-ADVC-full.xml --debug -b 0.0.0.0 -bmanagement 0.0.0.0"
|
||||
$cmdArgs = "-c standalone-ADVCsvil-full.xml --debug -b 0.0.0.0 -bmanagement 0.0.0.0"
|
||||
|
||||
# Start JBoss
|
||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c", "set NOPAUSE=true && `"$startScript`" $cmdArgs" -NoNewWindow
|
||||
# Start JBoss - Modified to use Start-Process with RedirectStandardOutput
|
||||
$logFile = "$JBOSS_HOME\standalone\log\server.log"
|
||||
$processStartInfo = @{
|
||||
FilePath = $startScript
|
||||
ArgumentList = $cmdArgs
|
||||
RedirectStandardOutput = $logFile
|
||||
RedirectStandardError = "$JBOSS_HOME\standalone\log\server_error.log"
|
||||
WorkingDirectory = "$JBOSS_HOME\bin"
|
||||
NoNewWindow = $true
|
||||
PassThru = $true
|
||||
}
|
||||
|
||||
Write-Host "Starting JBoss and redirecting output to $logFile" -ForegroundColor Yellow
|
||||
$jbossProcess = Start-Process @processStartInfo
|
||||
|
||||
# Wait a few seconds to check if the process started successfully
|
||||
Start-Sleep -Seconds 10
|
||||
@ -82,7 +95,7 @@ if (Is-JBossRunning) {
|
||||
Write-Host "JBoss started successfully!" -ForegroundColor Green
|
||||
Write-Host "Admin console will be available at: http://localhost:9990" -ForegroundColor Yellow
|
||||
Write-Host "Remote debugging is enabled on port 8787" -ForegroundColor Cyan
|
||||
Write-Host "Check JBoss logs at: $JBOSS_HOME\standalone\log\server.log" -ForegroundColor Yellow
|
||||
Write-Host "Check JBoss logs at: $logFile" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "Error: JBoss failed to start. Check the logs at: $JBOSS_HOME\standalone\log\server.log" -ForegroundColor Red
|
||||
Write-Host "Error: JBoss failed to start. Check the logs at: $logFile" -ForegroundColor Red
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ $JBOSS_HOME = "C:\Dev2012\BUILDERS\jboss-eap-7.4"
|
||||
Write-Host "Stopping JBoss EAP 7.4..." -ForegroundColor Yellow
|
||||
|
||||
# Find and stop JBoss process
|
||||
$jbossProcess = Get-Process -Name "java" -ErrorAction SilentlyContinue |
|
||||
$jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" |
|
||||
Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" }
|
||||
|
||||
if ($jbossProcess) {
|
||||
Write-Host "Found JBoss process (PID: $($jbossProcess.Id))" -ForegroundColor Yellow
|
||||
Stop-Process -Id $jbossProcess.Id -Force
|
||||
Write-Host "Found JBoss process (PID: $($jbossProcess.ProcessId))" -ForegroundColor Yellow
|
||||
Stop-Process -Id $jbossProcess.ProcessId -Force
|
||||
Write-Host "JBoss process stopped" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "No JBoss process found running" -ForegroundColor Yellow
|
||||
|
Loading…
x
Reference in New Issue
Block a user