gpt4 book ai didi

r - docker化后如何获取golem应用生成日志?

转载 作者:行者123 更新时间:2023-12-02 19:14:33 26 4
gpt4 key购买 nike

我们有一个运行dockerized的golem应用程序,除了部署在docker容器中时不创建任何输出(日志语句)外,它运行良好。实际上,我们什至没有看到任何默认的 Shiny 服务器日志。
这是我们的“AirSensorDataViewer”魔像应用程序的app.R:

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(在带有所有必需软件包的基础镜像之上构建):
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文件:
# 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;
}

}
是否有人成功获得了dockerized golem应用来创建/写入docker容器中的文件?

最佳答案

我希望发布的问题可能对那些想这样做的人有所帮助,因为事实证明一切正常。
在过去的几个小时中,当我想检查容器日志文件时,我错误地输入了docker run ...。这将创建一个新的容器。
相反,在以下情况下,确实可以在/var/log/shiny-server/中找到日志文件:

docker exec -ti airsensor-dataviewer-desktop /bin/bash
ls /var/log/shiny-server/

关于r - docker化后如何获取golem应用生成日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64235035/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com