0

When using magit-gerrit for git gerrit reviews and magit-gerrit-ssh-creds is set then magit-gerrit assumes that there is a gerrit server and tries to connect to it using ssh subprocess. The problem is when I only have the gerrit server available when VPN is up. In that case I need to comment out the magit-gerrit settings to disable it. I could add i.e. ssh -o ConnectTimeout=1 to prevent the ssh timout to be too long. But what I actually want is some elisp function to test in advance i.e. on startup of emacs:

(setq magit-gerrit-ssh-creds "1.1.1.1")
(setq isserveronline (server-is-online magit-gerrit-ssh-creds))
...
(if isserveronline
   (require 'magit-gerrit))

Does anyone know such a function server-is-online (that maybe uses a ping...) Best would even be if it could run concurrently i.e. for some second (because normally I never start magit directly)

2
  • The server in the tags is not the server OP is asking about. It's the Emacs server, i.e. something that runs Emacs, not a network server. Other than that... well, what kind of test would satisfy you? That you can connect to a particular IP? That you can connect to the port 22 on that IP? That the other side responds to SSH client commands? That the other side accepts your credentials? Also, obviously, the server can go offline right after the test, negating your test... so, it's usually best to assume that the server is on, and deal with errors.
    – wvxvw
    Jul 4 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.