I found an issue running an API using background = TRUE in Backend server$start, the child processes aren't killed when you execute ApplicationProcess$kill.
I tried just changing the order, first killing the childs and after that kill the service but I don't know why it doesn't work properly. Usually it works just the first kill and restart but after that it starts to fail letting orphans the processes.
The ugliest part is the suppress warnings function but it's needed because system with intern = TRUE returns a warning if it doesn't find any child process.
Any comment please let me know,
And again thanks for all your contributions,
Abraham
sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS
Hi @dselivanov, I hope you are doing well,
Thank you for the package, it's great!
I found an issue running an API using
background = TRUE
inBackend server$start
, the child processes aren't killed when you executeApplicationProcess$kill
.Let me show you a minimal example:
I run this script using
Rscript api.R
, then I make some requests from R using my browser and Postman. If I check the processes info I see:After the 60 seconds when
api
was killed and restarted, I check again the processes and I see:As you can see the processes 67459 and 67486 are still alive and the PPID has changed from 67325 to 1955.
Looking into your code I found the issue is hereThe PPID is killed first and when this happens another (and different) PPID is assigned to the orphan processes
I tried just changing the order, first killing the childs and after that kill the service but I don't know why it doesn't work properly. Usually it works just the first kill and restart but after that it starts to fail letting orphans the processes.
After trying some ideas what I found works properly is (It is not the most elegant):
The ugliest part is the suppress warnings function but it's needed because
system
withintern = TRUE
returns a warning if it doesn't find any child process.Any comment please let me know,
And again thanks for all your contributions,
Abraham
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale: [1] LC_CTYPE=es_MX.UTF-8 LC_NUMERIC=C
[3] LC_TIME=es_MX.UTF-8 LC_COLLATE=es_MX.UTF-8
[5] LC_MONETARY=es_MX.UTF-8 LC_MESSAGES=es_MX.UTF-8
[7] LC_PAPER=es_MX.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_MX.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods
[7] base
other attached packages: [1] RestRserve_1.2.2
loaded via a namespace (and not attached): [1] compiler_4.2.2 backports_1.4.1 R6_2.5.1 parallel_4.2.2 [5] tools_4.2.2 Rcpp_1.0.12 uuid_1.2-0 Rserve_1.8-13
[9] checkmate_2.3.1 jsonlite_1.8.8 digest_0.6.35 mime_0.12