I am currently making an upstart job run as an unprivileged user like so:
start on started mongodb stop on runlevel  respawn respawn limit 10 100 env NODE_ENV=production pre-start script ulimit -n 2048 end script exec sudo -u mainuser /usr/bin/make -C /home/mainuser/app start-prod >> /home/mainuser/data/logs/app.log 2>> /home/mainuser/data/logs/app.err.log
This works good, with one exception: the log files
app.err.log are being written as root (root becomes the owner of these files).
How do I ensure that the log files are written by the unprivileged