Comments (5)
I figured this out. Basically I just copied Bakeware.Script and then added my genserver to the child list:
defmodule ElixtronAgent.Application do
use Application
def start(_type, _args) do
children = [
%{id: Task, restart: :temporary, start: {Task, :start_link, [&__MODULE__.main/0]}},
ElixtronAgent.Server
]
opts = [strategy: :one_for_all, name: __MODULE__.Supervisor]
Supervisor.start_link(children, opts)
end
def parse_args(args) do
{opts, word, _} =
args
|> OptionParser.parse(switches: [upcase: :open_browser])
opts
end
def do_stuff(opts) do
IO.inspect(opts)
maybe_open_browser(opts[:open_browser])
:ok
end
defp maybe_open_browser(nil), do: nil
defp maybe_open_browser(_) do
IO.puts("maybe_open_browser")
ElixtronAgent.Server.open_browser()
end
def main() do
get_argc!()
|> get_args()
|> parse_args()
|> do_stuff()
|> result_to_halt()
|> :erlang.halt()
catch
error, reason ->
IO.warn(
"Caught exception in #{__MODULE__}.main/1: #{inspect(error)} => #{
inspect(reason, pretty: true)
}",
__STACKTRACE__
)
:erlang.halt(1)
end
def get_argc!() do
...same
end
def get_args(argc) do
...same
end
def result_to_halt(result) do
...same
end
end
from bakeware.
So, I've attached my own genserver to the application, and I'm running into a couple problems:
- Only handle_call seems to work. Not sure why, and haven't independently tested outside of the bakeware app, so might be spurrious.
- The genserver seems to restart on every call (I have a log message every time it starts, it throws every time I call the application).
Any ideas on these two issues?
from bakeware.
I think I may be calling the agent incorrectly. I've made this work with the dev version, because I can start it, and then send it rpc calls. I'm pretty sure that what I'm doing wrong is starting the agent every time. I don't actually know how to run it in production and then make RPC calls to it.
from bakeware.
I got this working for an elixir talk I'll be giving tomorrow for ElixirToronto (https://www.meetup.com/TorontoElixir/events/278237262/). Feel free to join if you like.
Basically the goal is to use Elixtron as a background desktop application that accepts commands over a custom protocol (elixtron://Elixtron.open_browser()) that can be called directly from the browser. Those links can be authored by the live view, rendered on the page, and then calls are made directly to the assembled bakeware binary.
I put up a repo for my implementation here: https://github.com/johns10/elixtron, and here: https://github.com/johns10/elixtron_desktop
I got it pretty far in dev mode. I'd be interested in your feedback about how to tighten this up and deploy in production. I have some theories on the readme.
This is a fantastic library. I'm really happy with this implementation, and I'm hoping to ultimately replace my electron implementation of browser automation with it, and even to ship a self-contained desktop version of my liveview app that requires no internet connection.
Hoping to use it more in the future!
Regards,
John Davenport
from bakeware.
@johns10 That's awesome! Thanks for letting us know. I signed up for the meetup. I'm not sure if I'll be able to make it yet, but I'll try!
from bakeware.
Related Issues (20)
- bakeware messes up ssl library? HOT 8
- adding rlwrap HOT 5
- Each build I make on Windows 10 prints "The system cannot find the path specified." when ran HOT 11
- Only allow 1 app to run | Reuse the same .cache if appname is the same HOT 2
- Conflict with escript HOT 4
- Cache directory is not properly created automatically on first run.
- Error during `mix deps.compile` under Windows 10 HOT 4
- Windows executable is an empty file HOT 6
- Issue when home path contains spaces HOT 1
- Compilation error in CentOS 7.9
- Windows? HOT 2
- Include runtime NPM packages HOT 1
- Is it possible to setup a Windows Bakeware release in GitHub Actions? HOT 9
- Running on mobile devices? HOT 2
- Run the binary as PID 1 HOT 1
- [Knowledge share] Cross-compiling to Windows from Linux
- different behavior between with and without bakeware. HOT 3
- Ability to run detached HOT 3
- Missing `release` in `assembler` struct during bakeware.assemble HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bakeware.