rstudio / rstudio-docker-products

Docker images for RStudio Professional Products
https://hub.docker.com/u/rstudio
MIT License
66 stars 55 forks source link

Restart of rstudio-connect inside of running container *rstudio/rstudio-connect* #78

Open Mishco opened 3 years ago

Mishco commented 3 years ago

Hello,

I am using base image in docker:

$ /opt/rstudio-connect/bin/connect
2020/11/30 10:33:19 Resource limits: {"nofile":{"soft":1048576,"hard":1048576}}
2020/11/30 10:33:19 Starting RStudio Connect v1.8.4.2-2

I would like to restart rstudio-connect application inside of container (I would like to keep container running) for migration script and also for getting logs/backup. All this scripts required to have stopped application, but restart of app is not available to use it. I was able to install systemd, but not able to restart app:

$ systemctl status rstudio-connect
System has not been booted with systemd as init system (PID 1). Can't operate.
$ systemctl stop rstudio-connect
System has not been booted with systemd as init system (PID 1). Can't operate.

I also tried https://stackoverflow.com/questions/52197246/system-has-not-been-booted-with-systemd-as-init-system-pid-1-cant-operate but without success.

Is there any command for restart application itself ?

Do you have any other suggestion ? If yes, please add also in documentation. Thanks

colearendt commented 3 years ago

Sorry for missing this comment! Thanks for reaching out!

Unfortunately, there is not a way to "stop Connect" inside of the container as it is currently built because the container has Connect running as the primary process, and if that process dies, the container dies.

However, a couple of ways around this:

I'd love to hear your feedback to these handful of items, and to know if / where other pain points exist!

colearendt commented 3 years ago

Also, if you'd rather talk more specifically about your environment, you are always welcome to open a support ticket at support@rstudio.com to help discuss your options for getting Connect migrated / etc.

Mishco commented 3 years ago

@colearendt thanks for you comments. In the meantime I moved to postgresql database however I am still struggling with this stop/restart of application. Current problem is using password's in config file.

Is there any other way? Maybe there is a way in the current settings to encrypt the string value in another tool and pass only this encrypted value to the configuration?

Thanks

colearendt commented 3 years ago

Ugh. You're right - I'm sorry about that. I was mixing up the rscadmin tool with the usermanager. usermanager works while Connect is running if using a postgres database - rscadmin does not 😞 This is definitely something we need to fix.

What execution environment are you using for docker? Is it possible to do something like this (with any volumes / etc. for persistent data included)? You can run this alongside an existing node now that you are using postgres

docker run -it --privileged rstudio/rstudio-connect:1.8.6 /opt/rstudio-connect/bin/rscadmin configure --encrypt-config-value
Mishco commented 3 years ago

Hi @colearendt any updates on this issue ?

I was able to run your command and encrypt password for postgres in configuration file:

[Database]
Provider = postgres

[Postgres]
URL = "postgres://{username}:{long-encrypted-string}@{our-database}.database.azure.com/{table}"

However when I used this configuration I am not able to start this container with the same license.

...
Deactivating license ...
/usr/local/bin/startup.sh: line 15: /opt/rstudio-connect/bin/license-manager: No such file or directory
+ deactivate
+ echo 'Deactivating license ...'
+ /opt/rstudio-connect/bin/license-manager deactivate

Is there any other way to put encrypted password in config file ?

Thanks

colearendt commented 3 years ago

@Mishco Thanks for checking in! Unfortunately no updates in the product yet that will resolve this issue!

In the meantime, I am happy to help you get this working. It seems to me that there may be something going awry here, the /opt/rstudio-connect/bin/license-manager: No such file or directory error is quite concerning, as it suggests that Connect is not installed or a volume is masking the /opt/rstudio-connect directory (which will cause all manner of problems)

It may be easier to handle this as a support ticket - would you mind emailing support@rstudio.com , mentioning me / this issue, and including what information you can about your environment? (how things are architected / run - using compose, kubernetes, how you are running the containers, etc.)

Also, I believe you should put the "Password" into the Postgres.Password configuration field, rather than embedding it in the URL. This makes things simpler, and may be important to this mechanism functioning properly.

https://docs.rstudio.com/connect/admin/appendix/configuration/#Postgres.Password

Finally, are you using a command like this to mount the configuration file, once you have modified it (from the README)?

docker run -it --privileged \
    -p 3939:3939 \
    -v $PWD/data/rsc:/data \
    -v $PWD/connect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg \
    -e RSC_LICENSE=$RSC_LICENSE \
    rstudio/rstudio-connect:1.8.6.2