Last active
August 13, 2020 14:01
-
-
Save Ratsuky/8c19ee02ee46ebefb47acd9a1992d8fa to your computer and use it in GitHub Desktop.
Script for starting up a local nginx, php-cgi, redis instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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