title: Should init scripts daemonize a process & are pid's essential?
body: <p>I'm working on getting an init script written for the web-server <a href="https://github.com/rstudio/shiny-server" rel="nofollow">shiny-server</a> (<a href="https://github.com/rstudio/shiny-server" rel="nofollow">shiny-server</a> is a version of the <a href="http://www.r-project.org/" rel="nofollow">R</a> package shiny that allows you to run stand alone web-applications based on <a href="http://www.r-project.org/" rel="nofollow">R</a>).</p>
  
  <p>I'm working through the <a href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&amp;chap=4" rel="nofollow">Gentoo Handbook : Writing Init Scripts</a> and am reading the <a href="http://devmanual.gentoo.org/" rel="nofollow">Gentoo Developers Guide</a> (as my ultimate aim is to develop an ebuild for installing this on Gentoo, bit of a way to go though).</p>
  
  <p>I had some trouble getting the init script to start so asked on the <a href="https://groups.google.com/forum/?fromgroups=#!searchin/shiny-discuss/gentoo/shiny-discuss/7Biw0OauYz8/4GG0HnX695oJ" rel="nofollow">Shiny Google Group</a> for assistance and one of the developers provided a solution, but at the same time the question arose as to whether Gentoo expects...</p>
  
  <p>a) to have a pid file for each process started.</p>
  
  <p>b) whether it is "best practice" to fork and daemonize a process such as this under Gentoo.</p>
  
  <p>I don't know but am seeking advice to feed back to the developer(s) who seem very open and receptive to getting their software out there and working with distributions.</p>
  
  <p>Currently my init script, which works, looks like....</p>
  
  <pre><code>#!/sbin/runscript
  depend(){
      after net
  }
  start(){
    ebegin "Starting shiny-server"
    start-stop-daemon --start --exec /usr/bin/shiny-server &gt;&gt; /var/log/shiny-server.log 2&gt;&amp;1
    local _retval=$?
    eend "${_retval}"
  }
  stop(){
    ebegin "Stopping shiny-server"
    start-stop-daemon --start --exec /usr/bin/shiny-server &gt;&gt; /var/log/shiny-server.log 2&gt;&amp;1  
    local _retval=$?
    eend "${_retval}"
  }
  </code></pre>
  
  <p>Thanks in advance for your time,</p>
  
  <p>slackline</p>