github.com/polarismesh/polaris@v1.17.8/release/standalone/windows/run-windows.ps1 (about) 1 # Tencent is pleased to support the open source community by making Polaris available. 2 # 3 # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 # 5 # Licensed under the BSD 3-Clause License (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # https://opensource.org/licenses/BSD-3-Clause 10 # 11 # Unless required by applicable law or agreed to in writing, software distributed 12 # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 # specific language governing permissions and limitations under the License. 15 16 $ErrorActionPreference = "Stop" 17 18 function runPolarisServer() { 19 Write-Output "run polaris server ... " 20 $polaris_server_num = (Get-Process | findstr "polaris-server" | Measure-Object -Line).Lines 21 if ($polaris_server_num -gt 0) { 22 Write-Output "polaris-server is running, skip" 23 return 24 } 25 $polaris_server_dirname = (Get-ChildItem -Directory "polaris-server-release*")[0].Name 26 Push-Location $polaris_server_dirname 27 Start-Process -FilePath ".\\polaris-server.exe" -ArgumentList ('start') -WindowStyle Hidden 28 Write-Output "run polaris server success" 29 Pop-Location 30 } 31 32 function runPolarisConsole() { 33 Write-Output "run polaris console ... " 34 $polaris_console_num = (Get-Process | findstr "polaris-console" | Measure-Object -Line).Lines 35 if ($polaris_console_num -gt 0) { 36 Write-Output "polaris-console is running, skip" 37 return 38 } 39 $polaris_console_dirname = (Get-ChildItem -Directory "polaris-console-release*")[0].Name 40 Push-Location $polaris_console_dirname 41 Start-Process -FilePath ".\\polaris-console.exe" -ArgumentList ('start') -WindowStyle Hidden 42 Write-Output "run polaris console success" 43 Pop-Location 44 } 45 46 function runPolarisLimiter() { 47 Write-Output "run polaris limiter ... " 48 $polaris_limiter_num = (Get-Process | findstr "polaris-limiter" | Measure-Object -Line).Lines 49 if ($polaris_limiter_num -gt 0) { 50 Write-Output "polaris-limiter is running, skip" 51 return 52 } 53 $polaris_limiter_dirname = (Get-ChildItem -Directory "polaris-limiter-release*")[0].Name 54 Push-Location $polaris_limiter_dirname 55 Start-Process -FilePath ".\\polaris-limiter.exe" -ArgumentList ('start') -WindowStyle Hidden 56 Write-Output "run polaris limiter success" 57 Pop-Location 58 } 59 60 function runPrometheus() { 61 Write-Output "run prometheus ... " 62 $prometheus_num = (Get-Process | findstr "prometheus" | Measure-Object -Line).Lines 63 if ($prometheus_num -gt 0) { 64 Write-Output "prometheus is running, skip" 65 return 66 } 67 $prometheus_dirname = (Get-ChildItem -Directory "prometheus-*")[0].Name 68 Push-Location $prometheus_dirname 69 Start-Process -FilePath ".\\prometheus.exe" -ArgumentList ('--web.enable-lifecycle', '--web.enable-admin-api') -RedirectStandardOutput prometheus.out -RedirectStandardError prometheus.err -WindowStyle Hidden 70 Write-Output "run prometheus success" 71 Pop-Location 72 } 73 74 function runPushGateway() { 75 Write-Output "run pushgateway ... " 76 $pgw_num = (Get-Process | findstr "pushgateway" | Measure-Object -Line).Lines 77 if ($pgw_num -gt 0) { 78 Write-Output "pushgateway is running, skip" 79 return 80 } 81 $pgw_dirname = (Get-ChildItem -Directory "pushgateway-*")[0].Name 82 Push-Location $pgw_dirname 83 Start-Process -FilePath ".\\pushgateway.exe" -ArgumentList ('--web.enable-lifecycle', '--web.enable-admin-api') -RedirectStandardOutput pgw.out -RedirectStandardError pgw.err -WindowStyle Hidden 84 Write-Output "run pushgateway success" 85 Pop-Location 86 } 87 88 89 $fileContent = Get-Content port.properties 90 $fileContent = $fileContent -join [Environment]::NewLine 91 $config = ConvertFrom-StringData($fileContent) 92 $console_port = $config.'polaris_console_port' 93 $eureka_port = $config.'polaris_eureka_port' 94 $xdsv3_port = $config.'polaris_xdsv3_port' 95 $service_grpc_port = $config.'polaris_service_grpc_port' 96 $config_grpc_port = $config.'polaris_config_grpc_port' 97 $api_http_port = $config.'polaris_open_api_port' 98 $prometheus_port = $config.'prometheus_port' 99 $pushgateway_port = $config.'pushgateway_port' 100 $limiter_http_port = $config.'polaris_limiter_http_port' 101 $limiter_grpc_port = $config.'polaris_limiter_grpc_port' 102 103 function checkPort() { 104 $ports = $console_port, $eureka_port, $xdsv3_port, $prometheus_sd_port, $service_grpc_port, $config_grpc_port, $api_http_port, $prometheus_port, $pushgateway_port, $limiter_http_port,$limiter_grpc_port 105 foreach ($port in $ports) 106 { 107 $processInfo = netstat -ano | findstr "LISTENING" | findstr $port 108 if($processInfo) 109 { 110 Write-Output $processInfo 111 Write-Output "port $port has been used, exit" 112 exit -1 113 } 114 } 115 } 116 117 #检查端口占用 118 checkPort 119 # 运行server 120 runPolarisServer 121 # 运行console 122 runPolarisConsole 123 # 运行polaris-limiter 124 runPolarisLimiter 125 # 运行Prometheus 126 runPrometheus 127 # 运行Prometheus 128 runPushGateway