acrolink
How to find the PID of the Phoenix process when running the server using UNIX socket
I was able to do easily that when running on a TCP port by finding the PID by the TCP port. However, how to find the PID of mix phx.server when running upon a UNIX socket. I need the PID to be able to restart the server.
Marked As Solved
acrolink
Here is the simplest solution as proposed by @josevalim:
elixir --detached -e "File.write! 'pid', :os.getpid" -S mix phx.server && cat pid
Also Liked
rodrigues
Hi @acrolink, maybe this could help you? GitHub - OvermindDL1/pid_file · GitHub
acrolink
Even simpler by:
lsof /path/to/socket/phx_prod.socket | awk 'NR > 1 {print $2}'
NobbZ
I’d prefer to write the PID file from the application start, rather then doing it in this shell start wrapper, which might append arbitrary log output to the PID file if console logging is enabled or even worse if there are still calls to IO.puts and IO.inspect, then their output will end up in the PID file as well…
Alternatively if one didn’t want to, or isn’t able to, then shell capabilities should be used:
app start &
echo $! > /run/app.pid
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









