出于某种原因,elixir --detached 的 pid 不等于 $!
例如:
elixir --detached -S mix run --no-halt & echo $!
和
ps aux | grep 'mix run'
输出不同的pid。
这是正常行为吗?我试过 nohup,但它有不同的问题。
最佳答案
我遇到了同样的问题并找到了解决方案 here .
就我而言,我最终得到了
$ elixir --detached -e "File.write! 'tmp/pids/bot.pid', :os.getpid" -S mix run --no-halt
$ cat tmp/pids/bot.pid
21352
$ ps aux | grep mix
deployer 21352 50.2 9.1 2234544 45788 ? Sl 12:21 0:02 /usr/lib/erlang/erts-9.0/b
它可能看起来很丑,但它确实有效:)
关于bash - Elixir ——分离的pid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40898474/