Select to view content in your preferred language

Drain stopping an Individual ArcGIS Server service on an individual machine within a cluster

05-24-2018 03:53 AM
Status: Open
New Contributor III

Why isn't there a function within ArcGIS Server to shutdown a service on an individual machine within a site cluster?
We've had situations like I'm sure many others have, whereby one machine is locking an FGDB because the service has failed to stop on that machine, right? Then ArcGIS Server reports the machine is a status of "Stopping" or "Starting"

So what do you do? You have to "Use a sledgehammer to crack a nut!" i.e. shutdown the whole of ArcGIS Server on the offending node in order to get the SOCs to release their file handles on the FGDB, so you can then swap it out. Even, when the service has been set to schema locking: false? 

This isn't sometimes feasible to do especially when you're refreshing a service on a shared platform and general service demand is at peak and operating on just one node within a site is just not an option.

I know you have the ability to shutdown machine within a site but why not add the function to shutdown a service on that machine??

1 Comment

# DrainStop.ps1
$logdir = 'C:\Scripts\Logs'
$today = get-date -UFormat "%Y%m%dT%H%M"
$logFile = "$logdir\DrainStop_$today.log"
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName | Where-Object {$_.CommandLine -like "*$ServiceName*"}
foreach ($process in $processes) {
$returnval = $process.terminate()
$processid = $process.handle

if($returnval.returnvalue -eq 0) {
write-host "The process $ProcessName `($processid`) terminated successfully" | Out-File -FilePath $logFile -Append
else {
write-host "The process $ProcessName `($processid`) termination has some problems" | Out-File -FilePath $logFile -Append

Surely something like this can be done..?