I'm using the following /etc/init/jsonlog.conf upstart job:
description "jsonlog"
start on runlevel [23]
stop on runlevel [06]
respawn
script
cd /tmp
echo "about to listen"
/bin/nc -l 3333
echo "finished listening"
end script
post-stop script
sleep 1
end script
The problem is that nc exits immediately every time a client connects.
The required behaviour is that all data received (which is utf8 json) should end up in /var/log/upstart/jsonlog.log. This server is running Ubuntu 12.04LTS.
The nc command works correctly when run from a bash shell.
I'm making an assumption that this be something to do with stdin. I've tried using a -q -1 option, but it hasn't helped.
P.S. I'm fine with the fact that this will listen to only one client at a time.