Start Erlang on startup. - erlang

I'm working on using erlang development server. Is there a way fro me to start the erlang vm and continue from the commandline or add a script to the startup files? To be clear I want to start erlang and keep it running outside of the command prompt.

You can use the -detached flag. See http://www.erlang.org/doc/man/erl.html for more information.

I usually use scripts, which rebar create-node do provide. There is such commands as: start, stop, ping and attach. Although you must use erlang releases in order to use this scripts (at list take a look at template, maybe it would be helpful)

Related

pstack equivalent in erlang

When a Erlang system hangs I want to know what the system is doing during that time. For a c/c++ program, I can easily run the pstack, but I didn't find out a handy tool for this purpose in Erlang.
What is the pstack equivalent in Erlang?
Actually I want to check the running stack trace of the following process.
"/opt/couchbase/lib/erlang/erts-5.10.4.0.0.1/bin/beam.smp -P 327680 -K true -- -root /opt/couchbase/lib/erlang -progname erl --... "
and I started a new Erlang shell and start the webtool and check the appmon however I can't find the above application. What may cause this?
Thanks
Concerning pstack equivalent, have you read Erlang Profiling from official guide? It gives you lot of example on how to profile your application and find where your code stuck.
Another useful tools is observer it will show all working process, CPU usage, process stack and lot of more information.
If you don't see anything with these tools, you can try with Erlang debugger.
Now concerning couchbase, if your application is currently running, you can connect to it with Erlang shell and launch previous quoted commands and applications.
I don't know if you are using couchbase alone or with couchdb, but, if you want to use observer or other tools from command line, you can start couchdb with -i flag:
# -i use the interactive Erlang shell
couchdb -i
In case of your application run remotely without GUI, you can use etop, its a CLI alternative to observer. You can also dump etop output to file if you don't want to run it directly from your Erlang shell. IHMO, if you want more information concerning I/O or debug, use eprof, fprof and other profiling tools with dump file (see also eep profiling tool, easy to use).
Another alternative, if you are using SSH and want to see observer window, you can use X11Forwarding with ssh: ssh -X $yourserver or ssh -Y $yourserver and simply run observer:start(). in your Erlang shell.

getting process ID of a pub serve to then kill that thread/process

So when I run my Polymer Dart application, i use pub serve and the serve is created and served. It will stay running until until i break out of it. I was curious if there is a way to programmatically stop it.
One of the options I was looking at was looking at the running processes and then killing the pub serve process.
I was not sure though how i would get the process id to kill it, or unless there was another option.
Maybe someone has an even better approach to shutdown pub serve on the machine automatically, as a form of cleanup?
The issue I have noticed is that if i get the running proceesses, i only see "cmd" as a process so that isnt the best determining factor.
I was not sure if there was a way via pub on serve to get its process if, if it set a flag or global of sorts I could leverage
This is not a Dart or Pub question really, it's a Windows, MacOS, Linux etc. shell process control question.
The question is more suited to Stack Exchange Superuser https://superuser.com/ I believe. You could look over there for more detailed answer ... but ... assuming you are using the windows command prompt:
start /B starts a process in the background.
tasklist can be used to look up running process PIDs.
taskkill /PID kills a running process.
You can use help <command> or search for documentation.
I have not used these personally but it looks awkward as start /B does not give you the PID of the process it ran. Unix shells such as Bash have good facilities for running processes in the background. Windows Powershell may have better support also.

Changes in YAWS takes a while to take effect

When I modify a .yaws file it take a few (5, 10) seconds for changes to take effect, it it normal and Do I have to keep terminal open while I use YAWS server?
When you modify a .yaws file, Yaws recompiles it to an Erlang .beam file, which contains bytecode for the Erlang virtual machine, and reloads it. This won't be instantaneous of course, but it should not take 5-10 seconds; you should report a Yaws issue in that case, and please include a test case.
As for requiring a terminal, Yaws can run such that it gives you an interactive Erlang shell, or it can be run as a background daemon if you supply the --daemon command-line option. Yaws comes with a number of startup scripts for running it as a daemon on various operating systems.

Erlang shell - controlling two processes

I have a question about erlang shell and erlang vm.
We have to write simple client-server application in Erlang, but only for local enviroment, so no sockets or anything.
I wanted to write something resembling a communicator server, people could register and send messages to other people. The thing is that if I open up erl and start my server/register it I can control only one process from the erlang shell, so there is no fun in that because I can't talk to anybody.
Is it possbile to open 2 erlang shells that are connected to the same instance of vm or compile the client program, start the server from erlang shell and then run the compiled clients in the same vm?
It is possible to open two shells connected to one VM (regular and
rem shell).
You can control many processes from one shell, just spawn
them.
What you probably really want is many erl VMs talking to each
other, even on one host. Just run them in distributed mode (e.g. with
-sname) and from now on you can communicate with anyone with the same cookie.
One of places to look at while learning erlang: http://learnyousomeerlang.com/distribunomicon#alone-in-the-dark

Riak on Windows

I want to play with Riak http://riak.basho.com/ or a least get it running on a Windows system. I have downloaded the source code and compiled it but that's where I get stuck, how do I start it?
It does run, altough I havent managed to run it as a service yet.
Install CYGwin, install latest erlang, get source code, compile in cygwin
then the fun part, adjust according to your paths and place into a batch
c:\riak\rel\riak\erts-5.7.4\bin\erl -boot c:\riak\rel\riak\releases\0.8\riak -embedded -config c:\riak\rel\riak\etc\app.config -args_file c:\riak\rel\riak\etc\vm.args -- console
Regards
Looks like the riak source has several bash start scripts. You would have to convert those to a windows batch script equivalent. That could be a fairly interesting chore given how limited batch scripts are. Those start-*.sh files show how to start it up though so I'd start there.
The http://hg.basho.com/riak/src/tip/README Readme file has futher info on what each script does.
Riak can not be run on Windows, only on Linux and Mac.
An alternative is to run VMWare or VirtualBox and run Riak inside a Linux VM. Works great for me.
Running it inside docker instance works very well - this is in 2017 the only way to successfully run Riak on Windows. You could probably get something running using Cygwin but this will be very complex and unreliable. Running under Docker is currently the most idiomatic solution.

Resources