opencpu

OpenCPU Delete Session


I am creating multiple sessions in OpenCPU that produces some decently sized files (MB range). These files are stored on disk and accumulate over time. The disk on my system runs out after creating too many sessions over a short time. Once the disk is full,t he following error is returned when trying to run a new session:

Failed to create tempdir /tmp/RtmpLaEI3K/ocpu-temp/x0bcd653371. Check directory permissions.

Is there a way to delete sessions when I no longer need the files so that the disk won't fill up? I'm currently running OpenCPU in standalone mode by executing the below R script:

install.packages("opencpu",repos = "http://cran.us.r-project.org")
library("MyCustomProject")

ocpu_start_app("MyCustomProject")

I was unable to find anything in the OpenCPU API docs for deleting sessions.


Solution

  • After more research I believe the answer is no, cleaning sessions explicitly is not currently supported.

    A work around was to create a new R method that was exposed as an HTTP endpoint. This method would determine the temporary work directory used by opencpu by calling the tempdir() method. It would then receive the session id as an input argument and use it to delete all files in the temporary directory associated with the session.