Comments (9)
For our diode.io app - what we're doing in addition though is that we're using epmd to find the running instance and bring it to the front when there is an attempt to open another instance. That logic though hasn't made it back to elixir-desktop yet.
What I reported for the TodoApp can also be replicated in the diode app, therefore what you describe here doesn't work to reopen the Diode app on Linux, after closing it by clicking on the x
. What you describe here only works to reopen the app from the task bar or from the menu.
See my comment above:
I can also replicate the issue with your app downloaded from https://diode.io/downlo
If you want we can have a Google meet cal for me to show it live with the diode app.
from desktop-example-app.
Hm, unfortunately I can't reproduce that. I've updated some dependencies including desktop_deployment which does the actual binary generation. Can you try again with that? Also if the issues persists is there anything suspicious in the ~/TodoApp/tmp/log/*
files?
from desktop-example-app.
Hm, unfortunately I can't reproduce that.
My linux laptop doesn't have Erlang or Elixir installed. I hope this isn't what makes the difference.
I've updated some dependencies including desktop_deployment which does the actual binary generation. Can you try again with that?
Will try later when I finish my workday or maybe during lunch time.
Also if the issues persists is there anything suspicious in the ~/TodoApp/tmp/log/* files?
Will check them 👍
from desktop-example-app.
I have updated the git repo, removed deps
and _build
folder, built the release again and the problem persists.
The problem from the logs is that the port is already in use. This is because when I close the the TodoApp window, the server continues to run, and when I click the icon of the TodoApp again it tries to start the server with the same port. Shouldn't the Elixir server close when the the app window is closed?
Relevant logs bit:
=====
===== LOGGING STARTED Thu Apr 18 13:34:51 BST 2024
=====
heart_beat_kill_pid = 421902
[error] Failed to start Ranch listener TodoWeb.Endpoint.HTTP in :ranch_tcp:listen([cacerts: :..., key: :..., cert: :..., ip: {127, 0, 0, 1}, port: 46060]) for reason :eaddrinuse (address already in use)
[error] Running TodoWeb.Endpoint with cowboy 2.12.0 at http failed, port already in use
[notice] Application todo_app exited: exited in: TodoApp.start(:normal, [])
** (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: {:error, {{:shutdown, {:failed_to_start_child, TodoWeb.Endpoint, {:shutdown, {:failed_to_start_child, {:ranch_listener_sup, TodoWeb.Endpoint.HTTP}, {:shutdown, {:failed_to_start_child, :ranch_acceptors_sup, {:listen_error, TodoWeb.Endpoint.HTTP, :eaddrinuse}}}}}}}, {:child, :undefined, TodoWeb.Sup, {TodoWeb.Sup, :start_link, [[]]}, :permanent, false, :infinity, :supervisor, [TodoWeb.Sup]}}}
(todo_app 1.2.0) lib/todo_app.ex:33: TodoApp.start/2
(kernel 9.2.3) application_master.erl:293: :application_master.start_it_old/4
Kernel pid terminated (application_controller) ("{application_start_failure,todo_app,{bad_return,{{'Elixir.TodoApp',start,[normal,[]]},{'EXIT',{{badmatch,{error,{{shutdown,{failed_to_start_child,'Elixir.TodoWeb.Endpoint',{shutdown,{failed_to_start_child,{ranch_listener_sup,'Elixir.TodoWeb.Endpoint.HTTP'},{shutdown,{failed_to_start_child,ranch_acceptors_sup,{listen_error,'Elixir.TodoWeb.Endpoint.HTTP',eaddrinuse}}}}}}},{child,undefined,'Elixir.TodoWeb.Sup',{'Elixir.TodoWeb.Sup',start_link,[[]]},permanent,false,infinity,supervisor,['Elixir.TodoWeb.Sup']}}}},[{'Elixir.TodoApp',start,2,[{file,\"lib/todo_app.ex\"},{line,33}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,293}]}]}}}}}")
heart: Thu Apr 18 13:34:53 2024: Erlang is crashing .. (waiting for crash dump file)
heart: Thu Apr 18 13:34:54 2024: Executed "/home/exadra37/TodoApp/TodoApp daemon" -> 0. Terminating.
With the TodoApp window visible:
─exadra37@laptop ~/TodoApp
╰─➤ ps aux | grep -i todoapp
exadra37 430425 0.0 0.0 2832 1592 ? S 13:37 0:00 /home/exadra37/TodoApp/releases/1.2.0/../../erts-14.2.4/bin/run_erl -daemon /home/exadra37/TodoApp/tmp/pipe/ /home/exadra37/TodoApp/tmp/log/ /home/exadra37/TodoApp/releases/1\.2\.0/\.\./\.\./erts-14\.2\.4/bin/erl -noshell \+sbwt none -heart -kernel inet_dist_use_interface \{127\,0\,0\,1\} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q\=\=\=\= -name todo_app_430323\@127\.0\.0\.1 -config /home/exadra37/TodoApp/releases/1\.2\.0/sys -boot /home/exadra37/TodoApp/releases/1\.2\.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -args_file /home/exadra37/TodoApp/releases/1\.2\.0/vm\.args -extra --no-halt
exadra37 430426 0.0 0.0 2912 1060 pts/5 Ss+ 13:37 0:00 sh -c /home/exadra37/TodoApp/releases/1\.2\.0/\.\./\.\./erts-14\.2\.4/bin/erl -noshell \+sbwt none -heart -kernel inet_dist_use_interface \{127\,0\,0\,1\} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q\=\=\=\= -name todo_app_430323\@127\.0\.0\.1 -config /home/exadra37/TodoApp/releases/1\.2\.0/sys -boot /home/exadra37/TodoApp/releases/1\.2\.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -args_file /home/exadra37/TodoApp/releases/1\.2\.0/vm\.args -extra --no-halt
exadra37 430427 0.8 1.3 89975748 436196 pts/5 Sl+ 13:37 0:03 /home/exadra37/TodoApp/erts-14.2.4/bin/TodoApp.smp -sbwt none -SDio 5 -Q 65536 -- -root /home/exadra37/TodoApp -bindir /home/exadra37/TodoApp/erts-14.2.4/bin -progname erl -- -home /home/exadra37 -- -noshell -heart -kernel inet_dist_use_interface {127,0,0,1} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q==== -name [email protected] -config /home/exadra37/TodoApp/releases/1.2.0/sys -boot /home/exadra37/TodoApp/releases/1.2.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -- -- -extra --no-halt
exadra37 430440 0.0 0.0 3764 112 ? S 13:37 0:00 /home/exadra37/TodoApp/erts-14.2.4/bin/epmd -daemon
exadra37 431734 0.0 0.0 9216 2252 pts/1 R+ 13:43 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn -i todoapp
After closing the TodoApp window:
╭─exadra37@laptop ~/TodoApp
╰─➤ ps aux | grep -i todoapp
exadra37 430425 0.0 0.0 2832 1592 ? S 13:37 0:00 /home/exadra37/TodoApp/releases/1.2.0/../../erts-14.2.4/bin/run_erl -daemon /home/exadra37/TodoApp/tmp/pipe/ /home/exadra37/TodoApp/tmp/log/ /home/exadra37/TodoApp/releases/1\.2\.0/\.\./\.\./erts-14\.2\.4/bin/erl -noshell \+sbwt none -heart -kernel inet_dist_use_interface \{127\,0\,0\,1\} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q\=\=\=\= -name todo_app_430323\@127\.0\.0\.1 -config /home/exadra37/TodoApp/releases/1\.2\.0/sys -boot /home/exadra37/TodoApp/releases/1\.2\.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -args_file /home/exadra37/TodoApp/releases/1\.2\.0/vm\.args -extra --no-halt
exadra37 430426 0.0 0.0 2912 1060 pts/5 Ss+ 13:37 0:00 sh -c /home/exadra37/TodoApp/releases/1\.2\.0/\.\./\.\./erts-14\.2\.4/bin/erl -noshell \+sbwt none -heart -kernel inet_dist_use_interface \{127\,0\,0\,1\} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q\=\=\=\= -name todo_app_430323\@127\.0\.0\.1 -config /home/exadra37/TodoApp/releases/1\.2\.0/sys -boot /home/exadra37/TodoApp/releases/1\.2\.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -args_file /home/exadra37/TodoApp/releases/1\.2\.0/vm\.args -extra --no-halt
exadra37 430427 0.8 1.3 89975748 437888 pts/5 Sl+ 13:37 0:03 /home/exadra37/TodoApp/erts-14.2.4/bin/TodoApp.smp -sbwt none -SDio 5 -Q 65536 -- -root /home/exadra37/TodoApp -bindir /home/exadra37/TodoApp/erts-14.2.4/bin -progname erl -- -home /home/exadra37 -- -noshell -heart -kernel inet_dist_use_interface {127,0,0,1} -s elixir start_cli -mode embedded -setcookie LOZNLKTQ5GK4ZQ3UFBAPFCCLAILGMHGPAK3QYMVCJD7RIBZSVJ7Q==== -name [email protected] -config /home/exadra37/TodoApp/releases/1.2.0/sys -boot /home/exadra37/TodoApp/releases/1.2.0/start -boot_var RELEASE_LIB /home/exadra37/TodoApp/lib -- -- -extra --no-halt
exadra37 430440 0.0 0.0 3764 112 ? S 13:37 0:00 /home/exadra37/TodoApp/erts-14.2.4/bin/epmd -daemon
exadra37 431760 0.0 0.0 9216 2272 pts/1 S+ 13:44 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn -i todoapp
Both outputs have the same PIDs for the TodoApp. The only difference on the output is the PID for the grep command.
from desktop-example-app.
If you start the app in dev mode with mix run --no-halt
, then close the window, you can then see that the shell it's still attached to the Erlang VM, which only exits with the usual ctrl + c + c.
from desktop-example-app.
I can also replicate the issue with your app downloaded from https://diode.io/download/
from desktop-example-app.
I noticed that the app adds a menu bar and task bar icon from where I can quit and reopen the app later, but this isn't what I am using to close the app window.
Just to be sure we are on the same page, by closing the window, I mean clicking in the X
at the top right corner of the window. To open the app again I search for it in my applications and then I click on the app icon.
from desktop-example-app.
Maybe the problem is because you only shutdown the server on a :close_window
event if the the task bar is nil
?
Code here:
if taskbar == nil do
OS.shutdown()
{:noreply, ui}
else
:wxFrame.hide(frame)
{:noreply, ui}
end
from desktop-example-app.
Yeah, the logic is that when there is a taskbar icon defined, then closing the window doesn't exit the app. But when there is no taskbar icon you should get the behavior you want.
In case you want both e.g. have a taskbar icon but also close the app when the only window is closed, then we would need to expose a new configuration for that I think.
For our diode.io app - what we're doing in addition though is that we're using epmd to find the running instance and bring it to the front when there is an attempt to open another instance. That logic though hasn't made it back to elixir-desktop yet. Now I think it would be nicer to generalize that away from epmd and instead use the existing http port collision for checking and signalling. (E.g. handle the error you see in the logs and instead ask the running instance to show() the main window again).
from desktop-example-app.
Related Issues (12)
- How to start a macOS app? HOT 4
- Questions about access to system resources? HOT 1
- Fix the Windows launch script HOT 2
- Can't run example app HOT 1
- License? HOT 3
- Cant find ../node_modules/nprogress/nprogress.css HOT 1
- add item throw err? HOT 1
- Recurring error "key :todos not found in: %Desktop.Menu" HOT 1
- Application Icon does not work for Linux HOT 7
- Application does not work on Ubuntu 22.04 HOT 5
- Empty context menu in KDE HOT 3
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 desktop-example-app.