I have a simple upstart script:
start on started network-services respawn respawn limit 100 5 setuid www-data exec node /var/testapp/app.js >> /var/log/testapp.log 2>&1 post-start exec echo "Server was (re)started on $(date)" | mail -s "Crashing Server (re)starting" email@example.com
but because I'm running the node app as 'www-data' I don't have write permissions on testapp.log
What is the best approach to address that?
I would rather not pre-create the log file with 'www-data' as it's owner because I would like as few steps as possible for the setup. I also rather not run the app as 'www-data' with sudo :
exec sudo -u www-data node /var/testapp/app.js >> /var/log/testapp.log 2>&1
because I saw that when I do so the 'root' is also running the process and maybe u'm wrong but i see that as a security issue. If it's not a security issue - please enlighten me.