Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:49:45+00:00 2026-05-31T16:49:45+00:00

I am trying to find out whether it is possible to start a gen_server

  • 0

I am trying to find out whether it is possible to start a gen_server with a given state.

I would like to be able to set up a monitor/supervisor that restarts the server with its last valid state when this server crashes.

Any suggestion on how to tackle this problem would be very Welcome.

So far my only idea is to have a special handle_call/3 that changes the server state to the desired state when called, but I would like to avoid modifying the server module and handle this purely from my monitor/supervisor process if possible.

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:49:46+00:00Added an answer on May 31, 2026 at 4:49 pm

    gen_server:init takes argument Args. You can pass whatever state you want and set it as the state of the server. You can pass Args to start_link and it will pass it to init for you.

    http://www.erlang.org/doc/man/gen_server.html#Module:init-1

    http://www.erlang.org/doc/man/gen_server.html#start_link-3

    I think that in your case you might want to store the state in mnesia. That way you don’t have to take care of passing last valid state to the gen_server. In case you don’t want to start mnesia you can use ETS. Create public ETS in some process that won’t die and use it from your gen_server (note that when server that created ets dies, the ets is destroyed)

    http://www.erlang.org/doc/man/ets.html

    http://www.erlang.org/doc/man/mnesia.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out whether it is possible to engineer a SSRS report
I am trying to find out whether it is possible to check if a
I'm trying to find out whether I should be using business critical logic in
I'm trying to find out whether a Socket is currently connected - according to
What I'm trying to find out is whether there is some sort of equivalence
Possible Duplicate: Java Class.cast() vs. cast operator I am unsuccessfully trying to find out
I've been trying to work out whether it's possible to do the following sort
I am trying to find out whether a piece of content included via ajax,
I'm trying to find out whether a delete query executed properly. I know how
I'm trying to compare images to each other to find out whether they are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.