I am currently working in a project that involves a Shiny App and a Quarto Website, both of which are published on Posit Connect. The Shiny App is designed to allow users to modify parameters that are subsequently stored in an external PostgreSQL database when the user clicks a button. The Quarto Website is also connected to this PostgreSQL database and retrieves specific values from it.
Up until now, if a user wanted to alter a value on the Quarto Website, the workflow involves accessing the Shiny App, modifying the value, clicking on the button to update the database, and then navigating to the Quarto Website to click on the "Refresh Report" button located in the upper right corner of the screen.
However, my goal is to streamline this process. I aim to configure the Shiny App's button so that it not only saves the modified values to the external database, but also triggers a refresh of the Quarto Website with the newly updated database values. Essentially, I want the shiny button to perform the same function as the "Refresh Report" button. I want the user to be able to refresh the Quarto Website from the Shiny App.
I am now going to outline my approach and discuss the challenges I've been encountering. Please understand that due to confidentiality reasons, I am unable to share certain specifics. However, I will provide as much information as I can. The app in question functions correctly when run locally, but when the app is published on Posit Connect, it ceases to function as expected.
First, I incorporated the rsconnect::connectApiUser
function into the app to establish a connection between the app and Posit Connect.
rsconnect::connectApiUser(
server = "***",
account = "***",
apiKey = "***")
Next, I implemented a functionality on the server such that when the 'saveBtn' button is clicked, the app attempts to refresh the Quarto Website. This website is located in a subdirectory of the app.
observeEvent(input$saveBtn, {
# CODE THAT UPDATES THE POSTGRESQL DATABASE
rsconnect::deployApp(
appDir = "./web",
appName = "DocName", # replaced by the actual name of the Quarto Website
upload = TRUE,
launch.browser = getOption("rsconnect.launch.browser", is_interactive()),
logLevel = "quiet",
forceUpdate = TRUE,
python = NULL,
quarto = TRUE,
appVisibility = NULL
)
As previously mentioned, this method works perfectly in a local environment. This is that the Quarto Website on Posit Connect is refreshed with the new values storaged on the database. However, when the application is published on Posit Connect, an error subsequently arises.
An error has occurred
The application failed to start.
exit status 1
In summary, my objective is to refresh a Quarto website by clicking a button on a Shiny App. Both the app and the website are published on Posit Connect.
I am uncertain if this is even feasible, or if I need to completely revise my approach. Any suggestions or comments are greatly appreciated. Thank you in advance.