edeliver v1.8.0 Edeliver.Relup.Instructions.SuspendChannels

This upgrade instruction suspends the websocket processes

connected to phoenix channels to avoid that new channel events will be processed during the code upgrade / downgrade process. It will be appended to the instructions after the "point of no return" but before any application code is reloaded. It should be used in conjunction with and after the

Edeliver.Relup.Instructions.SuspendRanchAcceptors

instruction which avoids that new websockets processes for phoenix channels are started.

To make sure that the websocket connections can be found on the node, use this instruction after the

Edeliver.Relup.Instructions.CheckRanchConnections

instruction which will abort the upgrade if ranch (websocket) connections cannot be found in the supervision tree. Use the

Edeliver.Relup.Instructions.ResumeRanchAcceptors

instruction at the end of your instructions list to resume the websocket processes and reenable handling channel messages.

Suspending and resuming websocket processes for phoenix channels requires a recent phoenix version which handles sys events for websockets. It also requires that the builtin phoenix pubsub backend Phoenix.PubSub.PG2 is used for the phoenix channels.

Link to this section Summary

Functions

Returns name of the application. This name is taken as argument for the run/1 function and is required to access the acceptor processes through the supervision tree

Suspends a list of processes. Because suspending a process might take a while depending on the length of the message queue or duration of current operation processed by the pid, suspending is done asynchronously for each process by spawing a new process which calls :sys.suspend/2 and then waiting for all results before returning from this function. Be careful when using :infinity as timeout, because this function might hang for infinite time if one of the process does not handle sys events.

Calls the run/1 function of this module

This module depends on the Edeliver.Relup.Instructions.CheckRanchAcceptors and the Edeliver.Relup.Instructions.CheckRanchConnections module which must be loaded before this instruction for upgrades and unload after this instruction for downgrades.

Appends this instruction to the instructions after the "point of no return" but before any instruction which loads or unloads new code, (re-)starts or stops any running processes, or (re-)starts or stops any application or the emulator.

Suspends all websocket channels to avoid handling new channel events during the upgrade. This is possible only in recent phoenix versions since handling sys events is required for suspending. If an older version is used, a warning is printed that suspending is not supported.

Link to this section Functions

Link to this function

arguments(instructions, config)

arguments(
  %Edeliver.Relup.Instructions{
    changed_modules: term(),
    down_instructions: term(),
    down_version: term(),
    up_instructions: term(),
    up_version: term()
  },
  Edeliver.Relup.Config.t()
) :: term()

Returns name of the application. This name is taken as argument for the run/1 function and is required to access the acceptor processes through the supervision tree

Link to this function

bulk_suspend(processes, timeout \\ 1000)

bulk_suspend(processes :: [pid()], timeout :: pos_integer() | :infinity) ::
  :ok
  | {:errors, count :: pos_integer(), [{pid :: pid(), reason :: term()}]}
  | :not_supported

Suspends a list of processes. Because suspending a process might take a while depending on the length of the message queue or duration of current operation processed by the pid, suspending is done asynchronously for each process by spawing a new process which calls :sys.suspend/2 and then waiting for all results before returning from this function. Be careful when using :infinity as timeout, because this function might hang for infinite time if one of the process does not handle sys events.

Link to this function

call_this(arguments \\ [])

call_this(arguments :: [term()]) ::
  Instruction.instruction() | Instruction.instructions()

Calls the run/1 function of this module

from the relup file during hot code upgrade

Link to this function

dependencies()

dependencies() :: [instruction_module :: atom()]
dependencies() :: [Edeliver.Relup.Instructions.CheckRanchAcceptors]

This module depends on the Edeliver.Relup.Instructions.CheckRanchAcceptors and the Edeliver.Relup.Instructions.CheckRanchConnections module which must be loaded before this instruction for upgrades and unload after this instruction for downgrades.

Link to this function

insert_where()

insert_where() :: Instruction.insert_fun()

Appends this instruction to the instructions after the "point of no return" but before any instruction which loads or unloads new code, (re-)starts or stops any running processes, or (re-)starts or stops any application or the emulator.

Link to this function

modify_relup(instructions, config)

Callback implementation for Edeliver.Relup.Instruction.modify_relup/2.

Link to this function

run(otp_application_name)

run(otp_application_name :: atom()) :: :ok

Suspends all websocket channels to avoid handling new channel events during the upgrade. This is possible only in recent phoenix versions since handling sys events is required for suspending. If an older version is used, a warning is printed that suspending is not supported.