Launch app from Elixir then exit BEAM. (Personal task scheduler)

Hi,

I need to launch certain apps on work days, I need to run some checks via HTTP APIs and then maybe launch some other apps, etc.

I am not very good with bash, and some complex scenarios will be much simpler to handle with Elixir (call HTTP, parse response, parse a config file, etc).

But is it possible to start an app from an Elixir script (think Slack, Thunderbird, …) and then shutdown the BEAM while the app is still running?

It could be, but why not wrap the two together instead?

#!/bin/sh

elixir -S "script.exs" && exec open "http://example.com"

Now all you need to ensure, is that script.exs will exit with non-0 code on error.

However with a little of *NIX magic you could fork the process into the background and leave it running when the parent dies, however I think, than in your case, there are some tools that would handle all of that for you, if you would be so keen to extend about what you need exactly.

1 Like

I vote for the normal release and eval/rpc afterward mix release — Mix v1.11.4

2 Likes

I need to do some things like:

  • if Slack was not open by the script today already, and if we are in Monday…Friday, then open Slack.
  • If some Gitlab project API returns a non-empty list of issues, then open a tab in Firefox to a certain URL calculated from the issues list.

I know it could be done with unix commands but yeah, I would like to learn how to fork and “unlink” from the parent.