首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让golem应用程序在停靠时生成日志?

如何让golem应用程序在停靠时生成日志?
EN

Stack Overflow用户
提问于 2020-10-07 07:17:04
回答 1查看 115关注 0票数 1

我们有一个停靠的golem应用程序,除了在部署到停靠容器中时不会创建任何输出(日志语句)之外,它运行得很好。事实上,我们甚至没有看到任何默认的闪亮服务器日志。

这是我们的"AirSensorDataViewer“傀儡应用程序的app.R:

代码语言:javascript
复制
pkgload::load_all(export_all = FALSE, helpers = FALSE, attach_testthat = FALSE)
options( 
  golem.app.prod = TRUE, 
  shiny.port = 3838,
  shiny.host = '0.0.0.0'
)
AirSensorDataViewer::run_app()

这是我们的Dockerfile (它建立在一个包含所有必要包的基础镜像之上):

代码语言:javascript
复制
FROM mazamascience/airsensor-dataviewer-base:1.0.1

# Create the build zone, copy the local directory over to the docker image, build and install R package.
RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
RUN R -e 'remotes::install_local(upgrade="never")'

# Remove sample apps
RUN rm -rf /srv/shiny-server/

# copy app to image
COPY . /srv/shiny-server/asdv

# add .conf file to image/container to preserve log file
COPY ./shiny-server.conf  /etc/shiny-server/shiny-server.conf

# When run image and create a container, this container will listen on port 3838
EXPOSE 3838

# Avoiding running as root --> run container as user 'shiny' instead
# allow permission
RUN sudo chown -R shiny:shiny /srv/shiny-server
RUN chmod -R 755 /srv/shiny-server/asdv

# execute in the following as user --> imortant to give permission before that step
USER shiny

##run app
CMD ["/usr/bin/shiny-server.sh"]

最后,我们的shiny-server.conf文件:

代码语言:javascript
复制
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location /asdv/test/ {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server/asdv;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }

}

有没有人成功地获得了一个docker化的golem应用程序来创建/写入docker容器中的文件?

EN

回答 1

Stack Overflow用户

发布于 2020-10-07 07:51:21

我希望张贴的问题可能对那些想要这样做的人有所帮助,因为事实证明一切都很好。

在过去的几个小时里,当我想要检查容器日志文件时,我错误地键入了docker run ...。这将创建一个新的容器。

相反,当我执行以下操作时,确实会在/var/log/shiny-server/中找到日志文件:

代码语言:javascript
复制
docker exec -ti airsensor-dataviewer-desktop /bin/bash
ls /var/log/shiny-server/
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64235035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档