Skip to content

Commit

Permalink
close #481: emit a message when stop_server() is called (but no messa…
Browse files Browse the repository at this point in the history
…ge when the R session is ending)
  • Loading branch information
yihui committed Oct 9, 2020
1 parent d7a3df8 commit 0d75cb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 0.20.21
Version: 0.20.22
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Beilei", "Bian", role = "ctb"),
Expand Down
12 changes: 8 additions & 4 deletions R/serve.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,17 @@ powershell = function(command) {
#' @export
#' @rdname serve_site
stop_server = function() {
ids = NULL # collect pids that we failed to kill
quitting = isTRUE(opts$get('quitting'))
for (i in opts$get('pids')) {
# no need to kill a process started by processx when R is quitting
if (isTRUE(opts$get('quitting')) && inherits(i, 'AsIs')) next
if (proc_kill(i, stdout = FALSE, stderr = FALSE) != 0) {
warning('Failed to kill the process ', i, '. You may need to kill it manually.')
}
if (quitting && inherits(i, 'AsIs')) next
if (proc_kill(i, stdout = FALSE, stderr = FALSE) != 0) ids = c(ids, i)
}
if (length(ids)) warning(
'Failed to kill the process(es): ', paste(i, collapse = ' '),
'. You may need to kill them manually.'
) else if (!quitting) message('The web server has been stopped.')
opts$set(pids = NULL, served_dirs = NULL)
}

Expand Down

0 comments on commit 0d75cb0

Please sign in to comment.