atomic-chrome icon indicating copy to clipboard operation
atomic-chrome copied to clipboard

Add atomic-chrome-server-running-p

Open dakrone opened this issue 6 years ago • 3 comments

This adds a method (autoloaded) that can check whether the atomic-chrome server is running or not.

This will allow someone to do

(when (not (atomic-chrome-server-running-p))
  (atomic-chrome-start-server))

Resolves #18

dakrone avatar Oct 23 '17 22:10 dakrone

@dakrone

This would be a good solution which is independent of OS. I tested it and it works on Linux, but it doesn't appear to work on Windows. atomic-chrome-server-runnning-p returns nil even though atomic-chrome server is already running. Do you find what the matter is?

alpha22jp avatar Oct 28 '17 00:10 alpha22jp

@alpha22jp hmm okay, I'll have to find a Windows machine and try to reproduce this, thanks for letting me know!

dakrone avatar Oct 30 '17 22:10 dakrone

    (defun ztlevi-atomic-chrome-server-running-p ()
      (cond ((executable-find "lsof")
             (zerop (call-process "lsof" nil nil nil "-i" ":64292")))
            ((executable-find "netstat") ; Windows
             (zerop (call-process-shell-command "netstat -aon | grep 64292")))))

    (if (ztlevi-atomic-chrome-server-running-p)
        (message "Can't start atomic-chrome server, because port 64292 is already used")
      (atomic-chrome-start-server))))

Hey, netstat works for windows and lsof works for Linux and mac. I see your way doing this, but I doubt that we should kill that process. Because all the time I start another emacs just to test some configuration...Well, that's my case. Not sure about yours.

ztlevi avatar Nov 08 '17 05:11 ztlevi