闪亮的应用程序未加载图形

时间:2019-01-01 11:45:46

标签: r shiny centos6 shiny-server

我有一个闪亮的应用程序,在我的本地计算机上运行得很好。我将应用程序部署在centos-release-6-9.el6.12.3.x86_64上运行的闪亮服务器上。加载的应用程序内容没有任何图形,如下所示:

enter image description here

然后我在JS consol中收到以下消息。

Loading failed for the <script> with source “http://mamged:3838/v01/shared/bootstrap/shim/respond.min.js”. v01:18:1
ReferenceError: Shiny is not defined[Learn More] v01:21:1
Loading failed for the <script> with source “http://mamged:3838/v01/shinyjs/shinyjs-default-funcs.js”. v01:38:1
ReferenceError: shinyjs is not defined[Learn More] v01:39:1
Loading failed for the <script> with source “http://mamged:3838/v01/message-handler.js”. v01:40:1
ReferenceError: jQuery is not defined[Learn More]
    [Exception... "Favicon at "http://mamged:3838/favicon.ico" failed to load: Not Found." nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource:///modules/FaviconLoader.jsm :: onStopRequest :: line 156" data: no]

我不确定出了什么问题。

编辑

我已经放置了一些示例代码以在服务器上重现该示例。

server.r

# clear console
cat("\014")


# Defining the size of file to be accepted. -1 to accept any size.
options(shiny.maxRequestSize = -1) 


# Clear workspace environment
rm(list = ls())    

# set locale
Sys.setlocale('LC_ALL','C') 

# main function
shinyServer(function(input, output,session) {

})

ui.r

library(shiny)
library(shinyjs)


filenames <- list.files(path = "data",pattern="\\.txt$")
names(filenames) <- gsub(pattern = "\\.txt$", "", filenames)
shinyUI(fluidPage(theme = "bootstrap.css",
                  (navbarPage("MAMGEDCDE",
                              position = c("fixed-top"),
                              fluid = TRUE, selected = "none", 
                              navbarMenu("Help", icon = icon("fa fa-infocircle"),

                                         tabPanel(
                                           list(
                                             a("Reference Manual", 
                                               target="_blank", href = "MAMGEDManual.pdf"),

                                             a("GPLs Supported",
                                               target="_blank", href="gpl.pdf"),

                                             a("Video Tutorials",
                                               downloadLink("AbsoluteExpression", " Absolute Expression", class=" fa fa-cloud-download"),
                                               downloadLink("DifferentialExpression", " Differential Expression", class=" fa fa-cloud-download")
                                               )
                                             ))
                                         ),

                              navbarMenu("Sample Data",
                                         tabPanel(
                                           list(
                                             downloadLink("AffymetrixData", " Affymetrix", class=" fa fa-cloud-download"),
                                             downloadLink("CodelinkData", " Codelink", class=" fa fa-cloud-download"),
                                             downloadLink("IlluminaData", " Illumina", class=" fa fa-cloud-download")
                                             ))
                                         ),

                              navbarMenu("Stand-Alone Version", icon = icon("fa fa-infocircle"),
                                         tabPanel(
                                           list(
                                             downloadLink("CodeandData", " MAMGED", class=" fa fa-cloud-download"),
                                             a("Stand-alone Manual", target = "_blank", href= "Stand-alone.pdf")
                                             )
                                           )
                                         )
                              )
                   ),

                  br(),
                  br(),
                  useShinyjs(),  ## initialize shinyjs to reset input files.
                  sidebarLayout(
                    sidebarPanel(
                      br(),

                      width = 4,
                      tabsetPanel(id = "tabs",
                                  tabPanel(id = "tab1", value = "tab1",
                                           h5("Upload Data Files"),
                                           br(),
                                           br(),

                                           fileInput("files", label = "Upload Data Files",
                                                     multiple = "TRUE",
                                                     accept=c('text/csv','text/comma-separated-values,
                                                              text/plain', '.csv','.cel','.TXT','.txt', '.zip')),

                                           uiOutput('Display_source_data'),
                                           br(),

                                           textInput("mailid", "Enter Email ID", placeholder = "Enter your email id")
                                           ),

                                  tabPanel(id = "tab2", value= "tab2",
                                           h5("Download Data",style="bold"),
                                           br(),
                                           br(),
                                           br(),
                                           textInput("jobid", "Enter Job ID", placeholder = "Enter your job id")
                                           )),
                      br(),
                      br(),

                      tags$head(tags$script(src = "message-handler.js")),
                      fluidRow(
                        conditionalPanel(
                          condition = "input.tabs == 'tab1'",
                          column(4,
                                 actionButton("Submit", label = "Submit"))
                          ),
                        conditionalPanel(
                          condition = "input.tabs == 'tab2'",
                          br(),
                          column(4,
                                 uiOutput("button")
                                 )),

                        column(4,
                               actionButton("Reset_Input", label = "Reset"))
                        ),
                      br()

                      ),

                    mainPanel(
                      titlePanel(
                        headerPanel( 
                          h2( "Analysis of Microarray Gene Expression Data",
                              align="center", style="bold"
                              )
                          )
                        ),
                      h5("test page")
                      )
                    )
                  ))

它在本地计算机上工作正常。

还有一件事情,我是否需要使用sudo -i R安装r软件包才能使其正常工作。我安装了没有sudo的所有软件包。

2 个答案:

答案 0 :(得分:0)

您的应用程序似乎缺少软件包。 默认情况下,检查您的应用程序日志 /var/log/shiny-server。 您也可以在配置文件中添加以下选项 /etc/shiny-server/shiny-server.conf

preserve_logs true; (at the top level)

在重新启动Shiny Server之后,请再次检查您的日志文件。 查找缺少的软件包或库。希望对您有所帮助。

答案 1 :(得分:0)

闪亮服务器可能正在以特殊用户身份运行。
假设用户名与其他服务器“ www-data”上的用户名相似。
现在的问题是,Web目录中的文件也许可以由闪亮服务器本身访问,但不能由客户端访问。
长话短说::调整所有文件的Unix文件权限,以便普通客户端可以访问这些文件。必须对所有公共可用的文件(例如图像,css文件和js文件)执行此操作。当然,它也可以包含您想要提供的其他任何文件,例如PDF,Office文件等。
unix权限必须为0744才能可读,最后一位是公开的,在您的情况下,可能会随chmod一起更改。
有关chmod的详细说明,您可以使用man chmod在命令行上显示手册页。

在某些环境中,通常将所有“公共”文件分类在名为“ public”或“ Public”的文件夹中,然后只需递归更改这些文件夹的文件权限即可。即使对于这里的公用文件夹,我也使用复数形式,因为在不同目录中可能总是存在多个具有相同名称的文件夹。在您的服务器上,shared文件夹似乎具有相同的功能,但并非所有公用文件都在其中排序。如果您更喜欢文件夹名称shared而不是public,则无需更改,而只需相应地调整权限。

我在上面提到服务器用户“ www-data”的原因是,Web目录中的文件应将此用户作为所有者,但不必公开。除了应在浏览器中直接调用的文件外,所有r文件都应为私有文件。因此,所有文件都分为公共文件和私有文件。可以使用chown来调整文件所有者,也可以在命令行递归中调用该文件所有者,而使用man chown也可以显示详细说明。

关于公共r文件,我不知道它们是否必须在闪亮的服务器上可执行,如果,则这些文件的文件权限必须为0755

更新
另外,还要确保所有文件都存在于www目录中,并且该域已链接到正确的文件夹。