developing shiny app as a package and deploying it to shiny server
<p>I am developing a shiny app and since I wanted to use automated testing and documentation of the function, I started to develop the interface within a package (as recommended <a href="https://stackoverflow.com/questions/37719503/automatic-documentations-of-functions-for-shiny-app-using-rstudio?noredirect=1#comment62920775_37719503" title="here">here</a>).</p>

<p>I develop this shiny app within RStudio and I have a <code>server.R</code> file which I can click on the <strong>Run App</strong> button within RStudio and everything works. I commit my package to a github repository and from this point I want to install it on my <em>R shiny server</em> using <code>devtools</code> and <code>install_github</code> function.</p>

<p>Now I am wondering how to start my app within the server. I was naively thinking to install the package and pointing to the <code>server.R</code> file, but this is somehow not working. Not sure where the problems are.</p>

<p>My second try was creating a file called <code>app.R</code> in a folder accessible by the shiny server and in this file I basically load my package, shiny and other needed packages but it somehow complains because of missing variables...</p>

<p>Can somebody give me an advice? I am also happy to answer any question since I am not sure how to ask for this problem properly. 
Thanks in advance.</p>

<p><strong>EDIT Deploying to shiny server</strong></p>

<p>Since <em>Colin D</em> was asking in the comments, how to deploy these packages on a shiny server, I wanted to demonstrate how I do this.</p>

<p>First of all I install my package on the shiny server directly via the command line as <strong>root</strong> with the following command.</p>

<pre><code>su - -c "R -e \"devtools::install_github('user/shinypackage')\"" 
</code></pre>

<p>The next step is to change the owner of the package folder</p>

<pre><code>chown -R shiny:shiny /usr/local/lib/R/site-library/shinypackage/
</code></pre>

<p>Then I restart the shiny server since this was sometimes problematic with caching or so.</p>

<pre><code>systemctl restart shiny-server
</code></pre>

<p>These are the steps I do when I update my shiny app. I do this normally again as root in a single line </p>

<pre><code>su - -c "R -e \"devtools::install_github('user/shinypackage')\"" &amp;  chown -R shiny:shiny /usr/local/lib/R/site-library/shinypackage/ &amp; systemctl restart shiny-server
</code></pre>

<p>One thing we still need to do is to setup the directory in the <code>shiny-server.conf</code> file. I just added the package path+the application directory where the <code>ui.R</code> and <code>server.R</code> is saved.</p>

<pre><code>  location /shinypackage {
    app_dir /usr/local/lib/R/site-library/shinypackage/application;
    log_dir /var/log/shiny-server;
  }
</code></pre>

<p>Then I have to restart the server again by using <code>systemctl restart shiny-server</code>.</p>

<p>This is in use on a Ubuntu Server.</p>