I currently trying to use websocket directive as a file-watcher endpoint(for jspm)
I found some curious behavior like below. Does anyone knows why that happens?
Problem
Caddy uses os/exec package from golang to call passed command.
But it cannot get stdout correctly in some situation(call node as a shell)
In that situation, websocket process immediately closed with no errors…
What already tried.
works! (point to local installed node_module with node command) websocket /watch "node ./node_modules/.bin/jspm-caddy-hmr"
not works… (point to local installed node_module as a shell) websocket /watch "./node_modules/.bin/jspm-caddy-hmr"
also not works… (point to global installed node_module) websocket /watch "jspm-caddy-hmr"
Additional information
I tried with websocketd(has a very similar feature to Caddy’s websocket directive) and it works smoothly. websocketd --port 8080 --devconsole ./node_modules/.bin/jspm-caddy-hmr
and my repository
ttps://github.com/subuta/jspm-caddy-hmr
If so, it means that Caddy couldn’t acquire stdout from your /watch command. How is Caddy supposed to read its output and forward it to the browser?
You say Caddy closes with no errors. Are you sure that’s the case? Did you run with -log stderr (as an example) and use the errors directive to see request-time errors? Can you post full logs?
@matt thanks for your response, and sorry for too late reply (not noticed your reply until now…)
so you are sure it is hitting this error handling line right here?
maybe not hitting this error(return statement) because caddy process lives in that situation.
If so, it means that Caddy couldn’t acquire stdout from your /watch command. How
is Caddy supposed to read its output and forward it to the browser?
I want caddy to forward my file-watcher(node.js based cli application) process’s stdout to browser.
You say Caddy closes with no errors. Are you sure that’s the case? Did you run with -log stderr (as an example) and use the errors directive to see request-time errors? Can you post full logs?
I retried as you suggests. and I got this error.
2016/07/31 23:05:27 http: response.Write on hijacked connection