Skip to content

Commit

Permalink
Fix http and redis start/stop in standalone mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jul 29, 2011
1 parent 18fdc91 commit b42052f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions lib/plugins/http.coffee
Expand Up @@ -36,18 +36,20 @@ module.exports = (settings) ->
else
next new Error('Failed to find appropriate "server.js" or "app.js" file')
args = args.join ' '
console.log args
http = exec args
done = false
interval = setInterval ->
clearInterval interval if done
, 100
#done = false
#interval = setInterval ->
#console.log done
#clearInterval interval if done
#, 100
http.on 'exit', (code) ->
if code is 0
then res.cyan settings.message_start
else res.red 'Error while starting HTTP server'
fs.unlinkSync pidfile if path.existsSync pidfile
res.prompt()
done = true
#done = true
if pipeStdout
http.stdout.pipe(
if typeof settings.stdout is 'string'
Expand All @@ -63,6 +65,10 @@ module.exports = (settings) ->
if detached
pidfile = settings.pidfile or '/tmp/http.pid'
fs.writeFileSync pidfile, '' + http.pid
setTimeout ->
res.cyan('HTTP server started').ln() if http
res.prompt()
, 500
shell.cmd 'http stop', 'Stop HTTP server', (req, res, next) ->
if not shell.isShell or settings.detach
pidfile = settings.pidfile or '/tmp/http.pid'
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/redis.coffee
Expand Up @@ -30,7 +30,7 @@ module.exports = (settings) ->
then fs.createWriteStream settings.stderr
else settings.stderr
)
if not shell.isShell and settings.detach
if not shell.isShell or settings.detach
pidfile = settings.pidfile or '/tmp/redis.pid'
fs.writeFileSync pidfile, '' + redis.pid
# Give a chance to redis to startup
Expand All @@ -42,7 +42,7 @@ module.exports = (settings) ->
if not shell.isShell or settings.detach
pidfile = settings.pidfile or '/tmp/redis.pid'
if not path.existsSync pidfile
return res.red('Failed to stop redis').prompt()
return res.red('Failed to stop redis: no pid file').prompt()
pid = fs.readFileSync pidfile
redis = spawn 'kill', [pid]
redis.on 'exit', (code) ->
Expand Down

0 comments on commit b42052f

Please sign in to comment.