-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r_bg() error in Docker container #293
Comments
You'll have to show how exactly you are running Docker, the full code, and also the full output. |
FROM rocker/r-ver:4.3.3
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libfontconfig1-dev \
libfreetype6-dev \
libfribidi-dev \
libharfbuzz-dev \
libicu-dev \
libjpeg-dev \
libpng-dev \
libsasl2-dev \
libssl-dev \
libtiff-dev \
libxml2-dev \
libxt6 \
make \
pandoc \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY renv.lock renv.lock
RUN Rscript -e "install.packages('renv')"
RUN Rscript -e "renv::restore()"
COPY . .
CMD ["Rscript", "bot_main.R"]
library(DBI)
library(RSQLite)
library(telegram.bot)
cat("R binary path:", Sys.which("R"), "\n")
cat("R binary directory:", dirname(Sys.which("R")), "\n")
db_con <- dbConnect(SQLite(), dbname = Sys.getenv("DB_PATH"))
start_telegram_bot <- function(path = ".",
bot_token,
admin_chat_id = NULL){
library(telegram.bot)
library(tidyverse)
library(DBI)
library(RSQLite)
library(glue)
db_con <- dbConnect(SQLite(), dbname = Sys.getenv("DB_PATH"))
bot <- Bot(token = bot_token)
updater <- Updater(token = bot_token)
source("./messageHandlers.R", local = T)
source("./commandHandlers.R", local = T)
source("./callbackQueryHandlers.R", local = T)
source("./filters.R", local = T)
bot$send_message(chat_id = Sys.getenv("ADMIN_CHAT_ID"), text = "Bot Avviato")
updater$start_polling(clean = T)
}
bot_bg_process <- callr::r_bg(
func = start_telegram_bot,
args = list(path = ".",
bot_token = Sys.getenv("BOT_TOKEN"),
admin_chat_id = Sys.getenv("ADMIN_CHAT_ID")),
# arch = Sys.which("R"),
# env = c(PATH = dirname(Sys.which("R"))), # Set the directory of the R binary
# cmdargs = c(
# Sys.which("R"),
# "--slave", "--no-save", "--no-restore"
# ),
stdout = "logs/output.log",
stderr = "logs/error.log",
supervise = TRUE
); bot_bg_process$is_alive() I cannot provide the entire code and folders, but you should be able to reproduce the error removing functions which require env variables. |
update:
|
after a thousand tries, even directly with processx, the problem were stdout = "logs/output.log",
stderr = "logs/error.log", even if thy works fine outside the container. |
Hi!
I have a script which works perfectly fine on my pc (windows) but stuck inside a docker container with rocker/r-ver:4.3.3 image.
In particular, following ChatGPT suggestions, for the container I tried with
arch
,env
andcmdargs
arguments SEPARATELY but The error is always the sameAny other suggestions?
thanks!
The text was updated successfully, but these errors were encountered: