Reputation: 534
I want to start these two commands in mix task:
System.cmd("cmd.exe", ["/c", "mix phx.server"], into: IO.stream(:stdio, :line))
System.cmd("cmd.exe", ["/c", "npm run dev"], cd: ".\\frontend", into: IO.stream(:stdio, :line))
However, both of them are blocking therefore, despite the order, second one never gets executed. How do I start both of them at once?
Upvotes: 0
Views: 263
Reputation: 121000
While the comment above by @sabiwara is absolutely correct, I am to address the exact problem stated explicitly.
One might use Task.async/1
or even just spawn/3
:
spawn(
System,
:cmd,
["cmd.exe", ["/c", "mix phx.server"], into: IO.stream(:stdio, :line)]
)
spawn(
System,
:cmd,
["cmd.exe", ["/c", "npm run dev"],
cd: ".\\frontend", into: IO.stream(:stdio, :line)]
)
Upvotes: 2