Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

httpd-stop doesn't stop the process #23

Open
jkdufair opened this issue Oct 21, 2019 · 8 comments
Open

httpd-stop doesn't stop the process #23

jkdufair opened this issue Oct 21, 2019 · 8 comments

Comments

@jkdufair
Copy link

I see that when I have a servlet and it has accepted at least one request (in my case to http://localhost:8080/?foo=bar), the process name is no longer httpd so the '#httpd-stop function does not stop the network process. Here is the code I'm running:

(require 'simple-httpd)
(setq-local httpd-serve-files nil)
(defservlet* ## text/plain (foo)
  (pp foo))
(httpd-start)
(httpd-stop)

There seem to be two processes now:

httpd <127.0... --      open    --                        --           Main         (network connection to 127.0.0.1:65246)
localhost       --      open    --                        --           Main         (network connection to localhost:8080)
@skeeto
Copy link
Owner

skeeto commented Oct 23, 2019 via email

@jkdufair
Copy link
Author

Thanks @skeeto. It would be nice to be able to stop all the processes. I only need to serve a single response to a single request (as part of an OAuth2 exchange). Would you be willing to accept a PR?

As an aside, I listened to your interview with Sascha Chua on her Emacs Chat podcast today - very entertaining! Thanks for all your awesome contributions to the world of Emacs!

@skeeto
Copy link
Owner

skeeto commented Oct 24, 2019 via email

@jkdufair
Copy link
Author

I think that would be a great approach! Additionally, I am trying to tread lightly and only stop if the "daemon" isn't already running. So I check the status and only start if not already started. I keep track of said state and kill processes only if it wasn't already running. My horrible hacks are here, starting around line 88. Perhaps there could be a few functions to handle this?

@skeeto
Copy link
Owner

skeeto commented Oct 25, 2019 via email

@skeeto
Copy link
Owner

skeeto commented Oct 25, 2019 via email

@jkdufair
Copy link
Author

Awesome thank you! I'll take a stab at it in the next few days.

@jcs090218
Copy link

jcs090218 commented May 18, 2023

I also have this issue, any update on this? 😕 Thanks!

(dolist (proc (process-list))
  (when (string-prefix-p "httpd" (process-name proc))
    (delete-process proc)))

This will work. 🤔

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants