asset.onInitialize(function()
  -- Disable the server, add production gui endpoint, and restart server.
  -- The temporary disabling avoids restarting the server on each property change.
  -- TODO: Add a trigger property to the module to restart the server "manually" and
  -- remove automatic restart on each property change, since frequent restarting seems to
  -- be unstable on MacOS.

  local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled")
  openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)

  local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
  directories[#directories + 1] = "screenshots"
  directories[#directories + 1] = "${SCREENSHOTS}"
  openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories)
  openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled)
end)

asset.onDeinitialize(function()
  -- TODO: Remove endpoints. As of 2019-10-29, OpenSpace sometimes
  -- crashes when endpoints are removed while the application is closing.
end)
