Skip to content

Commit

Permalink
imporve server closing
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaGanzin committed Jan 30, 2023
1 parent bafdc65 commit 8cbc605
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ module.exports = ({title = '', redirect}) => {
res.write(data)
})

if (closed) setTimeout(() => {
res.end()
console.log('one time server down')
process.exit()
}, 300)
setInterval(() => {
if (!closed) return
res.end()
console.log('one time server down')
process.exit()
}, 100)

}).listen({port: 80, host: '0.0.0.0'}, () => console.log('one time server up'))
} catch(e) {
Expand Down

0 comments on commit 8cbc605

Please sign in to comment.