Permalink
Browse files

trac pid better

  • Loading branch information...
1 parent 2ab9fc2 commit add1c84c403636fc03a2647edb8cf2fa917e08fe @ianb committed Jan 10, 2011
Showing with 79 additions and 49 deletions.
  1. +5 −3 server.coffee
  2. +8 −4 server.js
  3. +1 −0 static/index.html
  4. +29 −18 static/site.coffee
  5. +36 −24 static/site.js
View
@@ -32,16 +32,18 @@ jsonpRunProgram = (req, res) ->
console.log('args', JSON.stringify([params, params.command, args, {cwd: cwd, env: params.env}]))
proc = spawn(params.command, args, {cwd: cwd, env: env})
res.writeHead(200, 'Content-Type': 'text/javascript')
+ sendData = (data) ->
+ res.write(callback + '(' + JSON.stringify(callbackId) +
+ ', ' + JSON.stringify(data) + ')\n')
+ sendData(pid: proc.pid)
+ res.write('\n')
proc.stdout.on 'data', (data) ->
sendData(stdout: data.toString())
proc.stderr.on 'data', (data) ->
sendData(stderr: data.toString())
proc.on 'exit', (code, signal) ->
sendData(code: code)
res.end()
- sendData = (data) ->
- res.write(callback + '(' + JSON.stringify(callbackId) +
- ', ' + JSON.stringify(data) + ')\n')
envProgram = (req, res) ->
View
@@ -51,6 +51,13 @@
res.writeHead(200, {
'Content-Type': 'text/javascript'
});
+ sendData = function(data) {
+ return res.write(callback + '(' + JSON.stringify(callbackId) + ', ' + JSON.stringify(data) + ')\n');
+ };
+ sendData({
+ pid: proc.pid
+ });
+ res.write('\n');
proc.stdout.on('data', function(data) {
return sendData({
stdout: data.toString()
@@ -61,15 +68,12 @@
stderr: data.toString()
});
});
- proc.on('exit', function(code, signal) {
+ return proc.on('exit', function(code, signal) {
sendData({
code: code
});
return res.end();
});
- return sendData = function(data) {
- return res.write(callback + '(' + JSON.stringify(callbackId) + ', ' + JSON.stringify(data) + ')\n');
- };
};
envProgram = function(req, res) {
res.writeHead(200, {
View
@@ -20,6 +20,7 @@
<link rel="stylesheet" type="text/css" href="site.css" />
<link rel="stylesheet" type="text/css"
href="jscrollpane/jquery.jscrollpane.css" />
+<link rel="icon" type="image/png" href="/prompt.png" />
</head>
<body>
View
@@ -188,14 +188,15 @@ class Console
clearConsole: ->
$('.command-set, .incomplete-command-set', this.el).remove()
+ this.scroller.reinitialise()
+ this.scroller.scrollToBottom()
this.persist()
## UI-related routines:
inputKeyup: (event) ->
if event.type != 'keyup'
return
- console.log('event', event, event.which)
if event.which == 13
# Enter
this.runInputCommand()
@@ -220,6 +221,9 @@ class Console
inputEl = $('input.input', this.el)
inputEl.val(this.history[this.historyPos])
return false
+ if event.which == 82 and event.altKey
+ # alt-R
+ return false
runInputCommand: ->
inputEl = $('input.input', this.el)
@@ -240,7 +244,7 @@ class Console
((node) =>
display = node.toCommand()
cmd.text(display)
- cmd.attr(title: node.toXML())
+ #cmd.attr(title: node.toXML())
this.writeEl(div)
parts = node.toArgsNoInterpolate()
command = new Command(parts[0], parts[1...], this.cwd(), this.env())
@@ -299,22 +303,6 @@ class Console
),
)
- dataReceived: (id, data) ->
- console.log 'got data', id, data, data.code?
- if data.stdout? or data.stderr?
- if data.stdout?
- cls = 'stdout'
- else
- cls = 'stderr'
- this.write(data.stdout || data.stderr, cls, id)
- # Ignore the other stuff
- if data.code?
- if id
- el = $('#' + id, this.el)
- el.removeClass('incomplete-command-set')
- el.addClass('command-set')
- this.persistSoon()
-
persist: ->
if not this.persistRestored
return
@@ -337,6 +325,29 @@ class Console
this.scroller.scrollToBottom()
this.persistRestored = true
+ dataReceived: (id, data) ->
+ console.log 'data', id, data
+ if data.stdout? or data.stderr?
+ if data.stdout?
+ cls = 'stdout'
+ else
+ cls = 'stderr'
+ this.write(data.stdout || data.stderr, cls, id)
+ # Ignore the other stuff
+ if data.code? and id
+ el = $('#' + id, this.el)
+ el.removeClass('incomplete-command-set')
+ el.addClass('command-set')
+ el = $('.cmd', el)
+ if el.attr('title').search(/pid/) != -1
+ title = el.attr('title')
+ title = title.replace(/pid\:\s*\d+\s*/, '')
+ el.attr('title', title)
+ this.persistSoon()
+ if data.pid? and id
+ el = $('.cmd', $('#' + id, this.el))
+ console.log 'el', el
+ el.attr(title: 'pid: ' + data.pid + ' ' + el.attr('title'))
expandWildcard = (callback, pattern, cwd, env) ->
base = pattern
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit add1c84

Please sign in to comment.