Questions tagged [gen-server]

gen_server stands for "generic server", a module behaviour in Erlang.

315 questions
0
votes
1 answer

Erlang basic general server debugger output interpretation

I'm having some trouble with an Erlang module. Here is the one that I wrote: -module(basic_gen_server). -export([start/1, call/2, cast/2]). start(Module) -> register(server, spawn(basic_gen_server,gen_server_loop,[Module, Module:init()])),…
Nikhil Shinday
  • 1,096
  • 1
  • 9
  • 21
0
votes
3 answers

Detect when new file is added to a directory

How can I detect a new file being added to a specific directory? What I am looking for is something like an event_listener for when a new file is created. I am not interested in using a loop that keeps searching the directory for new files because I…
0
votes
1 answer

Erlang gen_server communication

If I have several instances of server, how can I pass info from one to another, for example: I have this: ... -record(id,{name,hash}). -record(state, {id ,m, succ, pred}). start(Name, M) -> gen_server:start_link({local, Name}, ?MODULE,…
Rebeca SO
  • 15
  • 1
0
votes
1 answer

Exception when running Cowboy start_listener()

I have followed http://maplekeycompany.blogspot.in/2012/03/very-basic-cowboy-setup.html link, but when I run this project it shows me crash report which tell that cowboy start_listener() is undefined. =CRASH REPORT==== 12-Aug-2014::10:08:06 === …
nadim
  • 776
  • 1
  • 12
  • 26
0
votes
2 answers

gen_server:call is failing with exception exit

I am running Erlang R16B03-1 (erts-5.10.4) at OS X 10.9.2. Erlang was installed by using brew. And I am trying to run a gen_server module. -module(logger). -author("evangelosp"). -behaviour(gen_server). %% API -export([start/0, stop/0,…
Evan P
  • 1,767
  • 1
  • 20
  • 37
0
votes
3 answers

Perform a synchronous operation on a dynamically generated gen_server

I am having a hard time wrapping my head around the correct way to make calls against a gen_server instance dynamically created by a supervisor with a simple_one_for_one child strategy. I am attempting to create data access controls as gen_servers.…
MichaelMilom
  • 3,024
  • 1
  • 16
  • 25
0
votes
3 answers

Erlang gen_server processes with timeout

I have to implement erlang gen_server processes which are alive for hours. But after timeout gen_server process should be killed. These processes are started dynamically so dynamical supervising is used. The idea is to use timer:apply_after() on…
0
votes
3 answers

no_proc exception from gen_server

when executing the below code gen_server is raising an exception -module(drop). -behaviour(gen_server). -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, …
user3382006
  • 69
  • 1
  • 7
0
votes
2 answers

Erlang: Why can't I link two gen_servers?

I have two gen_server modules. First serv.erl -module(serv). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2, start_link/0 ]). start_link() -> …
user2461860
  • 103
  • 5
0
votes
2 answers

Erlang Supervisor fail to start_child with no errors simple_one_for_one

the supervisor seems to fail silently starting child... Here's the supervisor -behaviour(supervisor). -export([start_socket/0, init/1, start_link/1]). -define(SSL_OPTIONS, [{active, once}, {backlog, 128}, …
TheSquad
  • 7,385
  • 8
  • 40
  • 79
0
votes
4 answers

How can i change the callback module of a gen_server in erlang? (gen_server:swap_handler)

I am building an app which can run in two modes. A sandbox mode and a production one. In sandbox mode, i want to make many checks in my gen_server against the database : if table doesn't exist then create it ; if column doesn't exist then add it ;…
lud
  • 1,941
  • 20
  • 35
-1
votes
1 answer

Erlang distributed - some nodes share 1 app

first of all, I'm sorry about my English, I hope you understand my question. My project is a distributed game in Erlang, its means that some computers (one node per computer) have to get access to an app. For example, 4 users from 4 computers play…
ersa
  • 81
  • 7
-1
votes
1 answer

How Can I Dynamically Create Genservers in Elixir?

I need to create processes runtime, to keep different states. I have a list of users in my :config, such as: config :backend, users: [user1, user2, user3] Is it possible to cycle through this list and create a supervisioned Agent or Genserver for…
Razinar
  • 727
  • 3
  • 13
  • 21
-1
votes
1 answer

Erlang gen_server implementation

In the code below, why is the module prime_server not loading? -module(prime_server). -behaviour(gen_server). -export([new_prime/1, start_link/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, …
user3382006
  • 69
  • 1
  • 7
-6
votes
1 answer

I have a receive block in erlang.If there is a timeout in my gen-server it returns ok but not the actual value.How to return actual value

%%sometimes my loop returns ok because of timeout how to write this code in proper way.when there is a timeout it just returns ok but not my actual value that i am assuming.In handle call i am calling a function loop() in the loop() function i am…
Nick Jonas
  • 103
  • 1
  • 7
1 2 3
20
21