erlang using 100% one of CPUs - erlang

I have situation when my project is frozen.
I see only 100% usage one of the CPUs (the rest is 0%, but I'm using SMP).
And my admin console says:
=ERROR REPORT==== 11-Feb-2011::00:45:00 ===
** Node 'node#example.com' not responding **
** Removing (timedout) connection **
After that I cannot connect to the node.
If I'm programming with C++ I can make a debug build and when such situation happens I can attach to my process and see the code where it is looping.
But how can I do it in Erlang? How can I get the call stack or something to help me understand what is really wrong?
Thank you for any help.

You can compile your module with debug information in the command line:
$ erlc +debug_info module.erl
Or in Erlang shell:
1> c(module, debug_info).
ok
When you have already started your process, you have an option to attach to the working process. Start the debugger in your erlang shell:
2> debugger:start().
The debugger window will appear. From menu select Module -> Interpret and select the appropriate module, to which you want attach in the Interpret Dialog window. When you did, you will see your module in the right window of debugger.
Now select Process -> Attach, Attach Process window should appear.

if the erlang distribution has shutdown you cannot use any remote debugging as you cannot connect to the node. You would have to connect to the pipes created by the VM at startup if configured to do so. See the http://www.erlang.org/doc/man/run_erl.html about how to do that.
You also might want to checkout this thread for a reason why your system is behaving the way it is: http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:55859:201101:jconogbffcaogeijbdkl

Related

Trying to run a Robot Framework Test Case against a Windows app with Appium Server - possible?

I am using Robot Framework with the RIDE IDE. I have an Appium Server session running. As a first try, I want to write a Robot Framework test case to open an instance of the Windows notepad. Firstly, is this even possible, or am I misguided?
Appium
The following are the settings used:
Remote Host: 127.0.0.1
Remote Port: 4723
Remote Path: /
SSL: disabled
The "Desired Capabilities" are set as represented by the following JSON:
{
"app": "C:\\Windows\\system32\\notepad.exe"
}
WinAppDriver
It is running on port 4723.
RIDE IDE
The following test case is being executed:
*** Settings ***
Library AppiumLibrary
*** Test Cases ***
TC0
Open Application http://localhost:4723/wd/hub app=C:\Windows\System32\notepad.exe
This yields the following error:
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No application is open
What might be the cause of this?
Edit: Additional information - when executing the above test case, the following appears in the WinAppDriver console:
Per default AppiumLibrary will run Capture Page Screenshot on failure.
AppiumLibrary Documentation
Most likely sequence is as follow.
Test case try open notepad but fail.
Open Application http://localhost:4723/wd/hub app=C:\Windows\System32\notepad.exe
On this failure AppiumLibrary try Capture Page Screenshot but fails due to there is no open application since step 1 failed.
I believe you need to focus on troubleshooting why the app do not open properly.
If you like to suppress this failure you can you can set AppiumLibrary to not capture screen on failure in the import with run_on_failure=No Operation, see the linked documentation above.
Library AppiumLibrary run_on_failure=No Operation
Slightly unrelated but I just wanted to give a few tips with using winappdriver and robotframework as there isn't a lot of concise information out there.
I personally have found that running the winappdriver through appium has been slower than running the winappdriver standalone.
localhost is also slower than using 127.0.0.1 as your system has to resolve that address each time: https://github.com/microsoft/WinAppDriver/issues/1269
AppiumLibrary is still very tailored to Mobile automation so it is missing some of the usual things you would want in desktop automation such as 'drag and drop', 'mouse over element', keywords for controlling the driver setup/teardown, etc. RobotFramework-Zoomba's DesktopLibrary extends AppiumLibrary and adds a lot of these keywords if you would be willing to try that out. Keyword docs can be found here: https://accruent.github.io/robotframework-zoomba/DesktopLibraryDocumentation.html

rebar3: console not opening

This is a rebar3 release compiled and released without any error. (There was this line ( ===> Missing beam file elf_format <<"/usr/local/lib/erlang/lib/hipe-3.11.3/ebin/elf_format.beam">>) I guess that's something else).
There is a line in the error which says that there is another link using the same hostname. Seeing this I deleted all such projects of the same name and recompiled and re released.
Also when i try start option no output is shown and localhost:8080 is not started.(I have been trying to do the example on this link in rebar3 :- http://jordenlowe.com/title/Explain_like_I_am_5_-_Erlang_REST_Framework_Cowboy)
What is/could be the reason for this error.
The main error is: the name hello_erlang#you_host seems to be in use by another Erlang node which says that there is another running Erlang node with the same name. You can see a list of running Erlang node with following Erlang Port Mapper Daemon (epmd) command:
epmd -names
You must stop or kill currently running node with the desired node name and then start the new one.

Erlang - Is it possible to make the messages that appear on erlang shell appear on linux shell too?

I have created a small test application and when on a linux machine I would like to see the messages that appear on the erlang shell to appear on the linux as well. I am not sure how it could be done, but is it possible?
I am running the application in detached mode(erlang shell).
EDIT:
I meant the message passing to the linux shell.
Example:
When I start my application using,
test application <start/stop>
I would get a message on the Linux shell Test Application has successfully started
But if I was like copying files, I would like the progress of the file copy to be displayed on the Linux shell like,
Copy successful. Number of files copied : 1
Copy successful. Number of files copied : 2
....
So is it possible to do the above using the message passing from Erlang to Linux?
I believe you can use some logger for this purposes. For example lager can redirect logs to several facilities at the same time, e.g. file and erlang console.
Other option is to use "run_erl", utility which comes with erlang distribution and allows "redirect the standard input and standard output streams so that all output can be logged".
Try erl -man run_erl or you can see can generate "release" with rebar, it will generate startup scripts which use "run_erl".

mnesia doesn't restart with supervisor

I have a problem working with gen_server, supervisor and mnesia. I have supervisor:http://pastebin.com/8rkfrq7D
which fires server module which is starting mnesia. My problem is that when i write
erl
c(superv).
superv:start_link().
//it opens fine
C^
erl
c(superv).
superv:start_link().
** exception exit: shutdown
//if i try again start_link() it is working
I got this. I deleted part responsible for starting mnesia and it worked fine, so I expect that instant quit (by ctrl+c) doesn't close mnesia properly. Unfortunately even if I invoke mnesia:stop(), before quicking and invoke start_link() again it returns exception exit. Please help me to resolve this matter.
The not entirely right way to start mnesia is as an application.
application:start(mnesia).
before you start your application. It can be used when you are developing your system. For a real deployment, you want to generate a release with a boot-script. A release is a self-contained Erlang system you can start up on a foreign machine. You will write your own application, write a my_application_name.app file which contains a dependency on mnesia. Then you want to generate a release, typically with reltool and this release will then initialize by starting up mnesia before starting my_application_name. At least this is the real way to do it.
The tool like rebar can help you with maintaining your application and a reltool.config file for building your release.
Note that Mnesia needs a schema before it can start. A common trick is to have your release contain a default empty database which gets installed such that mnesias dir parameter points to it. Thus, if you start a newly generated system, it has a database to start from. And you can restart from scratch by re-installing the empty database. Check out FALLBACK.BUP in mnesia for hints on how to do this.
As for your errors, you can't start your server twice. The first time around, it registers itself under the atom server so a subsequent restart when it is already running will crash it. You can sometimes get a hint if you boot Erlang with the SASL application enabled. Either execute application:start(sasl) or run erlang like so:
erl -boot start_sasl
which substitutes the normal boot script with a variant that also starts SASL.

erlide, which eclipse/which packages?

I have downloaded eclipse 3.4 (java version) for MacOSX (carbon). I have tried to 'update' to the erlide, but see many (duplicated) options (many erlide, options that say 'only for erl SDK updates', etc.) Sometimes I get 403 errors when attempting to access http://erlide.org/update and http://erlide.sourceforge.net/update.
Finally, when I get some set of options installed, I either get errors like :
Loading of /Users/kevindtimm/Documents/eclipse-java-ganymede-SR2-macosx-carbon/eclipse/plugins/org.erlide.kernel.common_0.8.1.201005250801/ebin/erlide_kernel_common.beam failed: badfile
(hello_world#ktmac)1>
=ERROR REPORT==== 24-Nov-2010::19:17:32 ===
beam/beam_load.c(1768): Error loading function erlide_kernel_common:monitor/0: op put_string u u x:
please re-compile this module with an R14B compiler
or, when I've done different installations of erlide, I get no response in the console to :
hello:hello().
Does anybody have a good reference for how to load this plug-in and which items I should install?
-module(hello).
-export([hello/0]).
hello() -> io:write("Hello World\n").
[edit]
I have installed eclipse 3.6 (c++) as requested below, and the following code still can't find hello:hello().
%%file_comment
-module(hello).
%%
%% Include files
%%
%%
%% Exported Functions
%%
-export([hello/0]).
%%
%% API Functions
%%
%%
%% Local Functions
%%
hello() -> io:write("Hello World\n").
[/edit]
It might be a little late for you, but maybe for others my set up might avoid some frustrations.
I have OSX 10.6.5, 64-bit and Erlang R14B installed.
After several false starts, I found the following worked:
Download the C++ version of Eclipse (I use the latest Helios, 64-bit, OSX)
Once extracted, start Eclipse
Open Help | Eclipse Marketplace (wait whilst it fetches data)
Type erlide into the search field and click Go
Proceed to install by following the instructions
Restart Eclipse after installing plugins (always a good idea)
Next, define an Erlang runtime, because this is not picked up automatically:
Open Eclipse preferences
Expand the Erlang entry shown on the left-hand side (do not select Erlang)
In the expanded list click on the Installed Runtimes entry
Define your runtime as appropriate
Restart Eclipse
Failure to do the above steps first, (i.e. opening a different Erlang preferences pane) causes an internal UI error inside Eclipse, that prevents you from closing the dialog. Thus, forcing you to kill Eclipse.
Finally, it is necessary to define a launch configuration before you can run your Erlang code inside Eclipse:
Open Run | Run Configurations
Select Erlang application
Add new launch configuration
Enter a name for the application
On the Erlang tab:
Check required project
On the Runtimes tab:
Make sure node is defined as erlide
Check "Start the Erlang node if not already running
Click apply
Anyway, I hope it helps somebody out there.

Resources