mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Fixed Clans DatabaseError without error giving the server heart attacks.
This commit is contained in:
parent
f58d51d4a9
commit
cea5798b10
3 changed files with 71 additions and 3 deletions
|
@ -1,11 +1,79 @@
|
|||
cluster = require 'cluster'
|
||||
numCPUs = require('os').cpus().length
|
||||
|
||||
deaths = [
|
||||
'Killed by a soldier ant.'
|
||||
'Ascended.'
|
||||
'Killed by an invisible gnome lord.'
|
||||
'Died of starvation.'
|
||||
'Petrified by a cockatrice corpse.'
|
||||
'Poisoned by a rotted kobold corpse.'
|
||||
'Fell into a pit.'
|
||||
'Killed by brainlessness.'
|
||||
'Slipped while mounting a saddled pony called Rainbow Dash.'
|
||||
'Killed by a scroll of genocide.'
|
||||
'Choked on a tin of spinach.'
|
||||
'Killed by the wrath of Anhur.'
|
||||
'Killed by a jackal, while fainted from lack of food.'
|
||||
'Drowned in a pool of water by an electric eel.'
|
||||
'Killed by falling downstairs.'
|
||||
'Killed by an ape, while helpless.'
|
||||
'Burned by a tower of flame.'
|
||||
'Killed by Ms. Sipaliwini, the shopkeeper.'
|
||||
'Fell onto a sink.'
|
||||
'Killed by a killer bee, while praying.'
|
||||
'Crushed to death by a collapsing drawbridge.'
|
||||
'Crunched in the head by an iron ball.'
|
||||
'Killed by exhaustion.'
|
||||
'Caught itself in its own magical blast.'
|
||||
'Shot itself with a death ray.'
|
||||
'Killed by genocidal confusion.'
|
||||
'Killed by touching Excalibur.'
|
||||
'Killed by a hallucinogen-distorted dwarf.'
|
||||
'Dissolved in molten lava.'
|
||||
'Turned to slime by a green slime.'
|
||||
'Killed by sipping boiling water.'
|
||||
'A trickery.'
|
||||
'Escaped (in celestial disgrace)'
|
||||
'Killed by kicking a sink.'
|
||||
'Killed by a kitten called Steve, while sleeping.'
|
||||
'Went to heaven prematurely.'
|
||||
'Teleported out of the dungeon and fell to its death.'
|
||||
'Panic.'
|
||||
'Killed by a minotuar, while dressing up.'
|
||||
'Petrified by trying to help a cockatrice out of a pit.'
|
||||
'Killed by a luckstone.'
|
||||
'Killed by a panther, while taking off clothes.'
|
||||
'Killed by a watch captain called The Nymphmaster.'
|
||||
'Killed by a black pudding, while jumping around.'
|
||||
'Killed by a hallucinogen-distorted white unicorn, while praying.'
|
||||
'Choked on a slice of birthday cake.'
|
||||
'Killed by a long worm, while reading a book.'
|
||||
'Killed by a giant beetle, while vomiting.'
|
||||
'Killed by an invisible master mind flayer, while unconscious from rotten food.'
|
||||
'Burned by burning.'
|
||||
'Killed by an air elemental, while hiding from thunderstorm (with the Amulet).'
|
||||
'Killed by wedging into a narrow crevice.'
|
||||
'Killed by a carnivorous bag.'
|
||||
'Killed by axing a hard object.'
|
||||
'Killed by an iron ball collision.'
|
||||
'Killed by an alchemic blast.'
|
||||
'Killed by dangerous winds.'
|
||||
'Killed by psychic blast.'
|
||||
'Committed suicide.'
|
||||
'Squished under a boulder.'
|
||||
'Killed by colliding with the ceiling.'
|
||||
'Killed by sitting on an iron spike.'
|
||||
"Quit while already on Charon's boat."
|
||||
'Fell into a chasm.'
|
||||
'Turned to slime by a cockatrice egg.'
|
||||
]
|
||||
|
||||
if cluster.isMaster
|
||||
for i in [0...numCPUs]
|
||||
cluster.fork()
|
||||
cluster.on 'exit', (worker, code, signal) ->
|
||||
message = "Worker #{worker.id} died! Heart attack takin' a dump."
|
||||
message = "Worker #{worker.id} died! #{deaths[Math.floor Math.random() * deaths.length]}"
|
||||
console.log message
|
||||
try
|
||||
hipchat = require './server/hipchat'
|
||||
|
|
|
@ -79,7 +79,7 @@ ClanHandler = class ClanHandler extends Handler
|
|||
return @sendNotFoundError(res, err)
|
||||
Clan.findById clanID, (err, clan) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
return @sendDatabaseError(res, err) unless clan
|
||||
return @sendNotFoundError(res) unless clan
|
||||
return @sendForbiddenError(res) if clan.get('ownerID')?.equals req.user._id
|
||||
Clan.update {_id: clanID}, {$pull: {members: req.user._id}}, (err) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
|
|
|
@ -81,7 +81,7 @@ module.exports = class Handler
|
|||
sendBadInputError: (res, message) -> errors.badInput(res, message)
|
||||
sendPaymentRequiredError: (res, message) -> errors.paymentRequired(res, message)
|
||||
sendDatabaseError: (res, err) ->
|
||||
return @sendError(res, err.code, err.response) if err.response and err.code
|
||||
return @sendError(res, err.code, err.response) if err?.response and err?.code
|
||||
log.error "Database error, #{err}"
|
||||
errors.serverError(res, 'Database error, ' + err)
|
||||
|
||||
|
|
Loading…
Reference in a new issue