jonas_h
Sending messages from an external script to a running Elixir app
Hey everyone.
I would like to send messages from an external script to a running Elixir app. The script should be short-lived and terminate immediately after forwarding the message. It could of course be written in Elixir too and they’ll run on the same server.
Thanks!
Marked As Solved
axelson
beam_notify might be a good library to look into: GitHub - nerves-networking/beam_notify: Send a message from a shell script to the BEAM · GitHub
Also Liked
Nicd
Yep, I use something like this to update my blog when I have added a new post or modified an existing one:
sudo -u www-data /var/www/blog/bin/mebe rpc "GenServer.call(Mebe2.Engine.Worker, :refresh, 30_000)"
Mix releases include the “rpc” script builtin.
speeddragon
I think you can do this in multiple ways. Define a port to receive messages or use the rpc to send messages directly in elixir.
/path/to/_build/prod/rel/my_app/bin/my_app rpc "Genserver.cast(...)"
cenotaph
Really cool solution!
ps: Security Notes:
- I hope your document root is not pointed at
/var/www - You have
directory listingand all the othernice stuffdisabled with the defaultapacheor another unix handler - For the future please create a specific user for your projects, applications, scripts and put them into respective directories and
runfrom that location with thatuser
ie: blog
user: blog
homedir: /home/blog
$ > ps
... blog ...... /home/blog/bin/mebe ......








