github.com/polarismesh/polaris@v1.17.8/release/standalone/windows/uninstall-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 uninstallPolarisServer {
    19      Write-Output "uninstall polaris server ... "
    20      Get-Process | ForEach-Object($_.name) {
    21          if($_.name -eq "polaris-server") {
    22              $process_pid = $_.Id
    23              Write-Output "start to kill polaris-server process $process_pid"
    24              Stop-Process -Id $process_pid
    25              Start-Sleep -Seconds 2
    26          }
    27      }
    28      $target_polaris_server_pkg = (Get-ChildItem "polaris-server-release*.zip")[0].Name
    29      $polaris_server_dirname = ([io.fileinfo]$target_polaris_server_pkg).basename
    30      $exists = (Test-Path ".\\$polaris_server_dirname")
    31      if ($exists) {
    32          Write-Output "start to remove $polaris_server_dirname"
    33          Remove-Item ".\\${polaris_server_dirname}" -Recurse
    34      }
    35      Write-Output "uninstall polaris server success"
    36  }
    37  
    38  function uninstallPolarisConsole {
    39      Write-Output "uninstall polaris-console ... "
    40      Get-Process | ForEach-Object($_.name) {
    41          if($_.name -eq "polaris-console") {
    42              $process_pid = $_.Id
    43              Write-Output "start to kill polaris-console process $process_pid"
    44              Stop-Process -Id $process_pid
    45              Start-Sleep -Seconds 2
    46          }
    47      }
    48      $target_polaris_console_pkg =  (Get-ChildItem "polaris-console-release*.zip")[0].Name
    49      $polaris_console_dirname = ([io.fileinfo]$target_polaris_console_pkg).basename
    50      $exists = (Test-Path $polaris_console_dirname)
    51      if ($exists) {
    52          Write-Output "start to remove $polaris_console_dirname"
    53          Remove-Item ".\\${polaris_console_dirname}" -Recurse
    54      }
    55      Write-Output "uninstall polaris console success"
    56  }
    57  
    58  function uninstallPolarisLimiter {
    59      Write-Output "uninstall polaris-limiter ... "
    60      Get-Process | ForEach-Object($_.name) {
    61          if($_.name -eq "polaris-limiter") {
    62              $process_pid = $_.Id
    63              Write-Output "start to kill polaris-limiter process $process_pid"
    64              Stop-Process -Id $process_pid
    65              Start-Sleep -Seconds 2
    66          }
    67      }
    68      $target_polaris_limiter_pkg =  (Get-ChildItem "polaris-limiter-release*.zip")[0].Name
    69      $polaris_limiter_dirname = ([io.fileinfo]$target_polaris_limiter_pkg).basename
    70      $exists = (Test-Path $polaris_limiter_dirname)
    71      if ($exists) {
    72          Write-Output "start to remove $polaris_limiter_dirname"
    73          Remove-Item ".\\${polaris_limiter_dirname}" -Recurse
    74      }
    75      Write-Output "uninstall polaris limiter success"
    76  }
    77  
    78  function uninstallPrometheus {
    79      Write-Output "uninstall prometheus ... "
    80      Get-Process | ForEach-Object($_.name) {
    81          if($_.name -eq "prometheus") {
    82              $process_pid = $_.Id
    83              Write-Output "start to kill prometheus process $process_pid"
    84              Stop-Process -Id $process_pid
    85              Start-Sleep -Seconds 2
    86          }
    87      }
    88      $target_prometheus_pkg =  (Get-ChildItem "prometheus-*.zip")[0].Name
    89      $prometheus_dirname = ([io.fileinfo]$target_prometheus_pkg).basename
    90      $exists = (Test-Path $prometheus_dirname)
    91      if ($exists) {
    92          Write-Output "start to remove $prometheus_dirname"
    93          Remove-Item ".\\${prometheus_dirname}" -Recurse
    94      }
    95      Write-Output "uninstall prometheus success"
    96  }
    97  
    98  function uninstallPushGateway {
    99      Write-Output "uninstall pushgateway ... "
   100      Get-Process | ForEach-Object($_.name) {
   101          if($_.name -eq "pushgateway") {
   102              $process_pid = $_.Id
   103              Write-Output "start to kill pushgateway process $process_pid"
   104              Stop-Process -Id $process_pid
   105              Start-Sleep -Seconds 2
   106          }
   107      }
   108      $target_pgw_pkg =  (Get-ChildItem "pushgateway-*.zip")[0].Name
   109      $pgw_dirname = ([io.fileinfo]$target_pgw_pkg).basename
   110      $exists = (Test-Path $pgw_dirname)
   111      if ($exists) {
   112          Write-Output "start to remove $pgw_dirname"
   113          Remove-Item ".\\${pgw_dirname}" -Recurse
   114          return
   115      }
   116      Write-Output "uninstall pushgateway success"
   117  }
   118  
   119  # 卸载 server
   120  uninstallPolarisServer
   121  # 卸载 console
   122  uninstallPolarisConsole
   123  # 卸载 limiter
   124  uninstallPolarisLimiter
   125  # 卸载 prometheus
   126  uninstallPrometheus
   127  # 卸载 pushgateway
   128  uninstallPushGateway