defmodule Server do
  use GenServer

  @impl true
  def init(opts) do
    {:ok, opts}
  end

  @impl true
  def handle_call(:sleep, _from, state) do
    Process.send_after(self(), :wakywaky, :timer.seconds(10))
    IO.puts("Hibernating")
    {:reply, :ok, state, :hibernate}
  end

  @impl true
  def handle_info(:wakywaky, state) do
    IO.puts("Waking up")
    {:noreply, state}
  end
end