本文整理汇总了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());
});