本文整理匯總了TypeScript中http.Server.close方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Server.close方法的具體用法?TypeScript Server.close怎麽用?TypeScript Server.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http.Server
的用法示例。
在下文中一共展示了Server.close方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: after
after(() => {
if (serverToClose) {
serverToClose.close();
}
});
示例2: after
after(() => {
if (server) {
server.close();
}
});
示例3: Promise
return new Promise((resolve, reject) => {
server.close((err) => {
if (err) {
return reject(err);
}
resolve();
})
})
示例4: catch
.catch(error => {
startupError = error;
try {
wsServer.close();
} catch (_error) {}
try {
httpServer.close();
} catch (_error) {}
})
示例5: after
after(() => {
server.close();
let cache = require.cache;
for (let path of Object.keys(cache)) {
if (/(?:[\\/]modules|-routes)[\\/]/.test(path)) {
delete cache[path];
}
}
});
示例6: shutdown
function shutdown(
server: Server,
logger: LoggerType,
response?: ServerResponse
) {
try {
if (server) {
server.close();
}
} catch (error) {
logger.error('shutdown: Error closing server', getPrintableError(error));
}
try {
if (response) {
response.end();
}
} catch (endError) {
logger.error(
"shutdown: couldn't end response",
getPrintableError(endError)
);
}
}
示例7: shutdownExpressServer
export function shutdownExpressServer(): void {
console.log("Express server is shutting down...");
server.close();
console.log("Express server shutdown.");
}
示例9: afterEach
afterEach(() => {
server.close();
});
示例10: Promise
return new Promise(resolve => {
if (!server) {
resolve();
}
server.close(() => resolve());
});