闪亮的应用程序未加载图形 [英] Shiny application not loading with graphics

查看:109
本文介绍了闪亮的应用程序未加载图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





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

 < script>的加载失败来源为 http:// mamged:3838 / v01 / shared / bootstrap / shim / respond.min.js。 v01:18:1 
ReferenceError:未定义Shiny [了解更多] v01:21:1
为< script>来源为 http:// mamged:3838 / v01 / shinyjs / shinyjs-default-funcs.js。 v01:38:1
ReferenceError:未定义Shinyjs [了解更多] v01:39:1
为< script>来源为 http:// mamged:3838 / v01 / message-handler.js。 v01:40:1
ReferenceError:未定义jQuery [了解更多]
[Exception ... Favicon位于 http:// mamged:3838 / favicon.ico未能加载:找不到。 nsresult: 0x80004005(NS_ERROR_FAILURE)位置: JS框架::资源:///modules/FaviconLoader.jsm :: onStopRequest ::第156行数据:否]

我不确定出了什么问题。



编辑



我已经将一些示例代码复制到了服务器。



server.r

 # clear console 
cat( \014)


#定义要接受的文件大小。 -1接受任何大小。
选项(shiny.maxRequestSize = -1)


#清除工作区环境
rm(list = ls())

#设置区域设置
Sys.setlocale('LC_ALL','C')

#主要功能
ShinyServer(function(input,output,session){

})

ui.r

  library(shiny)
库(shinyjs)


文件名<-list.files(path = data,pattern = \\.txt $)
名称(文件名)<-gsub(pattern = \\.txt $,,文件名)
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(参考手册,
target = _ blank,href = MAMGEDManual.pdf),

a(支持的GPL,
target = _ blank, href = gpl.pdf),

a(视频教程,
downloadLink( AbsoluteExpression, Absolute Expression,class = fa fa-cloud-download),
downloadLink( DifferentialExpression,差异表达式,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( fa fa-infocircle),
tabPanel(
list(
downloadLink( CodeandData, MAMGED,class = fa fa-cloud -download),
a(独立手册,target = _blank,href = Stand-alone.pdf)




),

br(),
br(),
useShinyjs(),##将Shinyjs初始化为重置输入文件。
sidebarLayout(
sidebarPanel(
br(),

width = 4,
tabsetPanel(id = tabs,
tabPanel( id = tab1,值= tab1,
h5(上传数据文件),
br(),
br(),

fileInput (文件,标签=上传数据文件,
多个= TRUE,
accept = c('text / csv','text /逗号分隔值,
text / plain','。csv','。cel','。TXT','。txt','。zip')),

uiOutput('Display_source_data'),
br(),

textInput( mailid,输入电子邮件ID,占位符=输入您的电子邮件ID)
),

tabPanel(id = tab2,值= tab2,
h5( Download Data,style = bold),
br(),
br(),
br (),
textInput( jobid,输入工作ID,占位符=输入您的工作ID)
)),
br(),
br() ,

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

列(4,
actionButton ( Reset_Input,标签= Reset))
),
br()

),

mainPanel(
titlePanel (
headerPanel(
h2(微阵列基因表达数据分析,
align = center,style = bold


),
h5(测试页)


))

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



还有一件事,我是否需要使用 sudo -i R 使其起作用。我安装的所有软件包都没有 sudo

解决方案

可能是闪亮的-服务器正在以特殊用户身份运行。

假定用户名与其他服务器上的 www-data类似。

现在的问题是,Web目录中的文件可能可以

长话短说:调整所有文件的Unix-file-rights,以便成为一个公共客户端可以访问文件。必须对所有公共可用的文件(例如图像,css文件和js文件)执行此操作。当然,它也可以包含您想要提供的其他任何文件,例如PDF,Office文件等。

Unix权利必须为 0744 为了便于阅读,最后一位数字是公开的,您的情况下可能用进行更改。

有关 chmod ,您可以在命令行上使用 man chmod 来显示手册页。



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

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



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



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


I have shiny app, which works perfectly fine on my local machine. I deployed the app on shiny-server running on centos-release-6-9.el6.12.3.x86_64. The content of the application is loaded without any graphics as shown below:

And I get the following message in 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]

I am not sure what is going wrong.

EDIT

I have put some sample code to reproduce the example on the server.

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")
                      )
                    )
                  ))

It works fine on the local machine.

One more thing, do I need to install r packages by using sudo -i R to make it work. I installed all the packages without sudo.

解决方案

Probably the shiny-server is running as a special user.
Assume the username is like on other servers "www-data".
The problem now is that the files in the web-directory perhaps can be accessed by the shiny-server itself, but not by the clients.
Long story short: adjust the Unix-file-rights for all the files, so that a common client can access the files. This must be done for all files that shall be public available like images, css-files and js-files. Surely it can include any other files too you want to serve like PDF, Office-files, etc.
The unix-rights have to be 0744 for being readable, the last digit is for the public and in your case probably to change with chmod.
For a detailed explanation concerning chmod you can show the man-page on commandline with man chmod.

In some environments it's common that all "public" files are sorted in folders named "public" or "Public", then just the file-rights of these folders have to be changed recursive. Even for the public folders here I use plural, as there can be several folders always with the same name in different directories. On your server the shared folder seems having the same functionality but not all public files are sorted in it. If you prefer the folder name shared over public, you never have to change but only to adjust the rights accordingly.

The reason that I mentioned about the server-user "www-data" above is that the files in the web-directory should have this user as owner, but are not required to be public. All you r-files should be private excepted the files which should be called directly in the browser. So all the files are separated in public and private. The file-owner can be adjusted with chown which can be called on commandline recursive too and with man chown you also can show the detailed description.

About public r-files I don't know if they have to be executable on shiny-servers, if so then the file-rights for these files have to be 0755.

Update
Also assure that all files are existent in your www-directory and that the domain is linked to the right folder.

这篇关于闪亮的应用程序未加载图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆