{"id":16656370,"url":"https://github.com/wnuqui/on_maintenance","last_synced_at":"2025-04-09T18:21:04.721Z","repository":{"id":62430169,"uuid":"88101675","full_name":"wnuqui/on_maintenance","owner":"wnuqui","description":"Maintenance mode for Plug based Elixir applications.","archived":false,"fork":false,"pushed_at":"2017-04-25T14:28:16.000Z","size":33,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-15T06:25:05.933Z","etag":null,"topics":["elixir","maintenance","maintenance-mode","maintenance-page","plug"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wnuqui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-12T22:27:53.000Z","updated_at":"2023-08-31T15:45:15.000Z","dependencies_parsed_at":"2022-11-01T19:47:16.978Z","dependency_job_id":null,"html_url":"https://github.com/wnuqui/on_maintenance","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fon_maintenance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fon_maintenance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fon_maintenance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fon_maintenance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wnuqui","download_url":"https://codeload.github.com/wnuqui/on_maintenance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085426,"owners_count":21045159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","maintenance","maintenance-mode","maintenance-page","plug"],"created_at":"2024-10-12T09:57:10.085Z","updated_at":"2025-04-09T18:21:04.704Z","avatar_url":"https://github.com/wnuqui.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"on-maintenance.png\" width=\"424\" height=\"155\"\u003e\n\u003c/p\u003e\n\n# Plug.OnMaintenance\n\n[![Build Status](https://travis-ci.org/wnuqui/on_maintenance.png?branch=master)](https://travis-ci.org/wnuqui/on_maintenance)\n[![Inline docs](http://inch-ci.org/github/wnuqui/on_maintenance.png?branch=master\u0026style=flat)](http://inch-ci.org/github/wnuqui/on_maintenance) [![Release](http://img.shields.io/github/release/wnuqui/on_maintenance.svg)](https://github.com/wnuqui/on_maintenance/releases/latest) [![Hex Version](https://img.shields.io/hexpm/v/on_maintenance.svg \"Hex Version\")](https://hex.pm/packages/on_maintenance)\n\n_Enable maintenance mode for your Plug based Elixir applications._\n\n**Plug.OnMaintenance**, an Elixir Plug, is used to disable access to your application for some length of time. Putting application in maintenance mode can be done programmatically or via mix tasks.\n\n## Contents\n\n- [Installation](#installation)\n- [Setup](#setup)\n- [\"retry-after\" response header](#retry-after-response-header)\n- [Example 503 responses (default)](#example-503-responses-default)\n- [Custom 503 Message](#custom-503-message)\n\n## Installation\n\nFor whatever reason, you want your Plug based Elixir application to be in maintenance mode for some length of time. `Plug.OnMaintenance` is what you need.\n\nAdd `on_maitnenance` to your project dependencies in mix.exs:\n\n```exs\ndefp deps do\n  [\n    ...\n    {:on_maintenance, \"~\u003e 0.7.0\"}\n  ]\nend\n```\n\nand do\n\n```bash\nmix deps.get\n```\n\nIn case of error, you may want to do\n\n```bash\nmix deps.update --all\n```\n\n## Setup\n\nNow that you have `on_maintenance` as your dependency, plug `Plug.OnMaintenance` in your `router.ex`. Let us say we have a Phoenix application.\n\n```elixir\npipeline :api do\n  plug Plug.OnMaintenance\n  # ...\nend\n```\n\nThen run this mix task\n\n```bash\nmix maintenance.init_config_store # creates sqlite db and add initial state of application (which is \"not in maintenance mode\")\n```\n\nThen run the application\n\n```bash\nmix phoenix.server # just in local\n```\n\nYou can enable/disable maintenance mode for your application via mix tasks below\n\n```bash\nmix maintenance.enable\nmix maintenance.disable\n```\n\nOr programmatically using these convenience methods below\n\n```elixir\nimport Plug.OnMaintenance.Util\n\non_maintenance?()     # will check if application is in maintenance mode\nenable_maintenance()  # put application in maintenance mode\ndisable_maintenance() # disable maintenance mode\n```\n\n## **retry-after** response header\n`503` response code should have a `retry-after` [header](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).\n\nYou can enable maintenance mode for your application and can\nspecify how long it would take via `--retry-after` option!\n\n```bash\nmix maintenance.enable --retry-after=300 # application will be on maintenance for 5 minutes.\n```\n\n## Example 503 responses (default)\n\nWhen in maintenance mode, your application will respond 503 to all http requests. The default message is _\"application on scheduled maintenance.\"_. Examples:\n\n### text/html response\n```html\n\u003chtml\u003e\n  \u003cbody\u003eApplication on scheduled maintenance.\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### application/json response\n```json\n{\"message\": \"Application on scheduled maintenance.\"}\n```\n\n### text/plain response\n```text\nApplication on scheduled maintenance.\n```\n\n## Custom 503 Message\n\nDefault message can be updated via `config.exs`\n\n```elixir\nuse Mix.Config\n\n# ...\n\nconfig :on_maintenance,\n  message: \"Service is currently in maintenance mode. Give us few minutes. Thanks!\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnuqui%2Fon_maintenance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwnuqui%2Fon_maintenance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnuqui%2Fon_maintenance/lists"}