Function fnStartApplicationPool([string]$appPoolName){
Import-Module WebAdministration
if ((Get-WebAppPoolState $appPoolName).Value -ne 'Started') {
Write-Host 'IIS app pool ' $appPoolName ' is not started. Starting.'
Start-WebAppPool -Name $appPoolName
Write-Host 'IIS app pool ' $appPoolName 'started'
}
}
Function fnStartAllApplicationPools() {
Import-Module WebAdministration
Write-Host "Starting all app pools"
$appPools = (Get-ChildItem IIS:\AppPools)
foreach ($appPool in $appPools) {
& fnStartApplicationPool -appPoolName $appPool.Name
}
}
#fnStartAllApplicationPools #start all applications pools
Function fnStopApplicationPool([string]$poolname) {
Import-Module WebAdministration
if ((Get-WebAppPoolState $appPoolName).Value -ne 'Stopped') {
Stop-WebAppPool -Name $appPoolName
}
}
Function fnStopAllApplicationPools(){
Import-Module WebAdministration
Write-Host "Starting all app pools"
$appPools = (Get-ChildItem IIS:\AppPools)
foreach ($appPool in $appPools) {
& fnStopApplicationPool-appPoolName $appPool.Name
}
}
#fnStopAllApplicationPools #start all applications pools
Tuesday, 26 February 2019
Powershell - starting and stopping multiple app pools
The following powershell script defines some functions in Powershell that can start up or stop all iis app pools on a server. It can be handy when you want to
test out concurrency issues and switch off all IIS app pools and start up again.
Saturday, 23 February 2019
Serializing a data contract with xml declaration and indented formatting
This code will serialize your object graph and also do xml indentation and adding an xml declaration at the top, using DataContractSerializer.
public static string SerializeObjectIndentedTo use it, just pass in your object and get an xml back!(T dataContract, bool omitXmlDeclaration = false) where T : class { using (var output = new StringWriter()) { using (var writer = new XmlTextWriter(output) { Formatting = Formatting.Indented }) { if (!omitXmlDeclaration) writer.WriteStartDocument(); var serializer = new System.Runtime.Serialization.DataContractSerializer(typeof(T)); serializer.WriteObject(writer, dataContract); return output.GetStringBuilder().ToString(); } } }
Saturday, 5 January 2019
Debugging Create React App javascript and tests in Visual Studio Code
This is a handy collection of configurations for debugging your Create React App javscript code (launching Chrome) and also tests generated with Create React App (CRA).
Note that the last one does not work probably if you have ejected the CRA. Here is the .vscode/launch.json file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Chrome debug 3000",
"type": "chrome",
"request": "launch",
"url": "https://localhost:3000",
"webRoot": "${workspaceRoot}/src"
},
{
"name": "Debug CRA Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": [
"test",
"--runInBand",
"--no-cache"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
Etiketter:
Javascript,
NodeJs,
React,
VisualStudioCode,
VsCode
Friday, 28 December 2018
Debugging http Node.js server requests and responses from shell
Here is a cool tip to inspect Node.js running an http process / server.
First off, we start a simple http server in Node.js like this:
const http = require('http');
const server = http.createServer((req, res) => {
res.end("Why hello world!
\n");
});
server.listen(4242, () => {
console.log("Server is running...");
});
This sets up a http server in Node.js. The http module is built-in in Node.js, we only have to require it (import in ES6).
Now, just enter the following (I use Windows Subsystem for Linux - WSL in this case) in your shell to export NODE_DEBUG environment variable:
export NODE_DEBUG=http
We can now see requests and responses in our Node.js server! (Image below uses Wsl-Terminal as our terminal against WSL).
Subscribe to:
Posts (Atom)
