Fork me on GitHub
#clojurescript
<
2022-12-08
>
Steph Crown06:12:37

Hi guys. Is there a way to detect if a shadow-cljs server instance is running before starting another one so that if it's running, I won't start another one but just hook up to this one.

thheller07:12:40

how are you starting it? all the regular commands already detect and connect on their own?

Steph Crown07:12:01

I am starting it from a Phoenix watcher. So when the Phoenix server starts, it automatically starts. The issue is whenever I kill the Phoenix server, the shadow-cljs server does not die, hence, when the Phoenix server starts again and tries to spin up shadow-cljs, it returns an exception about a server that's up.

thheller07:12:56

why doesn't the phoenix server kill the shadow-cljs instance when shutting down?

thheller07:12:09

again though: what command do you use to start shadow-cljs?

thheller07:12:39

if its through the regular shadow-cljs command it should already connect just fine. unless phoenix killed its runtime files in the .shadow-cljs dir

thheller07:12:58

maybe you should try a separate tool to run the phoenix server and shadow-cljs in parallel. if phoenix isn't capable of killing the processes it started that doesn't seem great

Steph Crown07:12:05

I use shadow-cljs watch app to start the server.

thheller07:12:54

that'll figure out if a server is running and connect to it

thheller07:12:04

unless its runtime files in .shadow-cljs are deleted by something else

Steph Crown07:12:31

What is its runtime file in .shadow-cljs, let me confirm that.

thheller07:12:34

there are files in that directory that the command will check to see if a server is running

thheller07:12:11

also caches and stuff. so the entire dir should be left alone and never be touched by anything but shadow-cljs

thheller07:12:35

no clue what phoenix does, just a guess

Steph Crown07:12:47

Alright, thanks.

Steph Crown07:12:07

I'll just try out some things here and see how it goes.

thheller07:12:49

the correct solution should be to just have phoenix kill shadow-cljs when it gets shut down

thheller07:12:00

leaving a lingering process is not a clean solution in either case

1