I have a node.js script which need to start at boot and run under the www-data user. During development I always started the script with:
su www-dat
rc.local only runs on startup. If you reboot and want the script to execute, it needs to go into the rc.0 file starting with the K99 prefix.
rc.local
rc.0