Skip to content

Instantly share code, notes, and snippets.

@Ratsuky
Last active August 13, 2020 14:01
Show Gist options
  • Select an option

  • Save Ratsuky/8c19ee02ee46ebefb47acd9a1992d8fa to your computer and use it in GitHub Desktop.

Select an option

Save Ratsuky/8c19ee02ee46ebefb47acd9a1992d8fa to your computer and use it in GitHub Desktop.
Script for starting up a local nginx, php-cgi, redis instance
$ServerPath = "D:\local_servers";
$appsToStart= @{
($ServerPath + '\redis\redis-2.4.5-win32-win64\64bit\redis-server.exe') =
"nil"
($ServerPath + '\php_ver\php-7.4.7-nts-Win32-vc15-x64\php-cgi.exe') =
"-b 127.0.0.1:9747 -c D:\local_servers\php_ver\php-7.4.7-nts-Win32-vc15-x64\php.ini"
('cd '+ $($ServerPath)+'\nginx\nginx-1.19.0\;start nginx.exe') =
"nil"
}
$processNames = 'redis-server', 'php-cgi', 'nginx'
foreach($processName in $processNames){
try {
Get-Process $processName -ea stop | Stop-Process -ea stop;
}
catch {
#Echo "Nothing to close for name --- $processName"
}
}
foreach ( $key in $appsToStart.GetEnumerator() ){
$holder = $key.Value
if( $holder -ne "nil" ){
Start-Process -NoNewWindow $key.Name "$($holder)"
} else {
Invoke-Expression $key.Name
}
}
foreach($processName in $processNames){
#echo "Checking $processName";
#tasklist /fi "imagename eq $processName.exe";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment