Upstart node.js working directory

前端 未结 2 620
无人共我
无人共我 2021-01-01 21:28

Starting Node.js with Upstart, when trying to access files within Node.js it cannot access them without using the full path. I need it to use the working directory.

相关标签:
2条回答
  • 2021-01-01 21:40

    The solution is to change directory within the script. In my case, the user is mynodeapp and the node files are in the users directory (/home/mynodeapp/).

    script
            chdir /home/mynodeapp/
            echo $$ > /var/run/mynodeapp.pid
            exec sudo -u mynodeapp node server.js >> /var/log/mynodeapp.sys.log 2>&1
    end script
    

    I have yet to find out what $$ means on the echo line or 2>&1. Maybe somebody could chime in with this if they know!

    0 讨论(0)
  • 2021-01-01 21:41

    You should use the chdir stanza as per the Upstart docs: http://upstart.ubuntu.com/cookbook/#chdir

    0 讨论(0)
提交回复
热议问题