parent
e118d639a0
commit
2753285b77
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
# Configuring instance
|
||||
You can configure your instance from admin interface. You need account with admin rights and little change in config file, which will allow settings dynamic configuration from database.
|
||||
|
||||
```elixir
|
||||
config :pleroma, :instance,
|
||||
dynamic_configuration: true
|
||||
```
|
||||
|
||||
## How it works
|
||||
Settings are stored in database and are applied in `runtime` after each change. Most of the settings take effect immediately, except some, which need instance reboot. These settings are needed in `compile time`, that's why settings are duplicated to the file.
|
||||
|
||||
File with duplicated settings is located in `config/{env}.exported_from_db.exs`. For prod env it will be `config/prod.exported_from_db.exs`.
|
||||
|
||||
## How to set it up
|
||||
You need to migrate your existing settings to the database. You can do this with mix task (all config files will remain untouched):
|
||||
```bash
|
||||
mix pleroma.config migrate_to_db
|
||||
```
|
||||
Now you can change settings in admin interface. After each save, settings are duplicated to the `config/{env}.exported_from_db.exs` file.
|
||||
|
||||
<span style="color:red">**ATTENTION**</span>
|
||||
|
||||
**<span style="color:red">Be careful while changing the settings. Every inaccurate configuration change can break the federation or the instance load.</span>**
|
||||
|
||||
*Compile time settings, which require instance reboot and can break instance loading:*
|
||||
- all settings inside these keys:
|
||||
- `:hackney_pools`
|
||||
- `:chat`
|
||||
- `Pleroma.Web.Endpoint`
|
||||
- partially settings inside these keys:
|
||||
- `:seconds_valid` in `Pleroma.Captcha`
|
||||
- `:proxy_remote` in `Pleroma.Upload`
|
||||
- `:upload_limit` in `:instance`
|
||||
|
||||
## How to remove it
|
||||
|
||||
1. Truncate or delete all values from `config` table
|
||||
```sql
|
||||
TRUNCATE TABLE config;
|
||||
```
|
||||
2. Delete `config/{env}.exported_from_db.exs`.
|
||||
|
||||
For `prod` env:
|
||||
```bash
|
||||
cd /opt/pleroma
|
||||
cp config/prod.exported_from_db.exs config/exported_from_db.back
|
||||
rm -rf config/prod.exported_from_db.exs
|
||||
```
|
||||
*If you don't want to backup settings, you can skip step with `cp` command.*
|
||||
|
||||
3. Set dynamic configuration to `false`.
|
||||
```elixir
|
||||
config :pleroma, :instance,
|
||||
dynamic_configuration: false
|
||||
```
|
||||
4. Restart pleroma instance
|
||||
```bash
|
||||
sudo service pleroma restart
|
||||
```
|
@ -0,0 +1,211 @@
|
||||
defmodule Pleroma.Docs.GeneratorTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias Pleroma.Docs.Generator
|
||||
|
||||
@descriptions [
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: Pleroma.Upload,
|
||||
type: :group,
|
||||
description: "",
|
||||
children: [
|
||||
%{
|
||||
key: :uploader,
|
||||
type: :module,
|
||||
description: "",
|
||||
suggestions:
|
||||
Generator.list_modules_in_dir(
|
||||
"lib/pleroma/upload/filter",
|
||||
"Elixir.Pleroma.Upload.Filter."
|
||||
)
|
||||
},
|
||||
%{
|
||||
key: :filters,
|
||||
type: {:list, :module},
|
||||
description: "",
|
||||
suggestions:
|
||||
Generator.list_modules_in_dir(
|
||||
"lib/pleroma/web/activity_pub/mrf",
|
||||
"Elixir.Pleroma.Web.ActivityPub.MRF."
|
||||
)
|
||||
},
|
||||
%{
|
||||
key: Pleroma.Upload,
|
||||
type: :string,
|
||||
description: "",
|
||||
suggestions: [""]
|
||||
},
|
||||
%{
|
||||
key: :some_key,
|
||||
type: :keyword,
|
||||
description: "",
|
||||
suggestions: [],
|
||||
children: [
|
||||
%{
|
||||
key: :another_key,
|
||||
type: :integer,
|
||||
description: "",
|
||||
suggestions: [5]
|
||||
},
|
||||
%{
|
||||
key: :another_key_with_label,
|
||||
label: "Another label",
|
||||
type: :integer,
|
||||
description: "",
|
||||
suggestions: [7]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :key1,
|
||||
type: :atom,
|
||||
description: "",
|
||||
suggestions: [
|
||||
:atom,
|
||||
Pleroma.Upload,
|
||||
{:tuple, "string", 8080},
|
||||
[:atom, Pleroma.Upload, {:atom, Pleroma.Upload}]
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: Pleroma.Upload,
|
||||
label: "Special Label",
|
||||
type: :string,
|
||||
description: "",
|
||||
suggestions: [""]
|
||||
},
|
||||
%{
|
||||
group: {:subgroup, Swoosh.Adapters.SMTP},
|
||||
key: :auth,
|
||||
type: :atom,
|
||||
description: "`Swoosh.Adapters.SMTP` adapter specific setting",
|
||||
suggestions: [:always, :never, :if_available]
|
||||
},
|
||||
%{
|
||||
key: "application/xml",
|
||||
type: {:list, :string},
|
||||
suggestions: ["xml"]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
group: :tesla,
|
||||
key: :adapter,
|
||||
type: :group,
|
||||
description: ""
|
||||
},
|
||||
%{
|
||||
group: :cors_plug,
|
||||
type: :group,
|
||||
children: [%{key: :key1, type: :string, suggestions: [""]}]
|
||||
},
|
||||
%{group: "Some string group", key: "Some string key", type: :group}
|
||||
]
|
||||
|
||||
describe "convert_to_strings/1" do
|
||||
test "group, key, label" do
|
||||
[desc1, desc2 | _] = Generator.convert_to_strings(@descriptions)
|
||||
|
||||
assert desc1[:group] == ":pleroma"
|
||||
assert desc1[:key] == "Pleroma.Upload"
|
||||
assert desc1[:label] == "Pleroma.Upload"
|
||||
|
||||
assert desc2[:group] == ":tesla"
|
||||
assert desc2[:key] == ":adapter"
|
||||
assert desc2[:label] == "Adapter"
|
||||
end
|
||||
|
||||
test "group without key" do
|
||||
descriptions = Generator.convert_to_strings(@descriptions)
|
||||
desc = Enum.at(descriptions, 2)
|
||||
|
||||
assert desc[:group] == ":cors_plug"
|
||||
refute desc[:key]
|
||||
assert desc[:label] == "Cors plug"
|
||||
end
|
||||
|
||||
test "children key, label, type" do
|
||||
[%{children: [child1, child2, child3, child4 | _]} | _] =
|
||||
Generator.convert_to_strings(@descriptions)
|
||||
|
||||
assert child1[:key] == ":uploader"
|
||||
assert child1[:label] == "Uploader"
|
||||
assert child1[:type] == :module
|
||||
|
||||
assert child2[:key] == ":filters"
|
||||
assert child2[:label] == "Filters"
|
||||
assert child2[:type] == {:list, :module}
|
||||
|
||||
assert child3[:key] == "Pleroma.Upload"
|
||||
assert child3[:label] == "Pleroma.Upload"
|
||||
assert child3[:type] == :string
|
||||
|
||||
assert child4[:key] == ":some_key"
|
||||
assert child4[:label] == "Some key"
|
||||
assert child4[:type] == :keyword
|
||||
end
|
||||
|
||||
test "child with predefined label" do
|
||||
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
|
||||
child = Enum.at(children, 5)
|
||||
assert child[:key] == "Pleroma.Upload"
|
||||
assert child[:label] == "Special Label"
|
||||
end
|
||||
|
||||
test "subchild" do
|
||||
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
|
||||
child = Enum.at(children, 3)
|
||||
%{children: [subchild | _]} = child
|
||||
|
||||
assert subchild[:key] == ":another_key"
|
||||
assert subchild[:label] == "Another key"
|
||||
assert subchild[:type] == :integer
|
||||
end
|
||||
|
||||
test "subchild with predefined label" do
|
||||
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
|
||||
child = Enum.at(children, 3)
|
||||
%{children: subchildren} = child
|
||||
subchild = Enum.at(subchildren, 1)
|
||||
|
||||
assert subchild[:key] == ":another_key_with_label"
|
||||
assert subchild[:label] == "Another label"
|
||||
end
|
||||
|
||||
test "module suggestions" do
|
||||
[%{children: [%{suggestions: suggestions} | _]} | _] =
|
||||
Generator.convert_to_strings(@descriptions)
|
||||
|
||||
Enum.each(suggestions, fn suggestion ->
|
||||
assert String.starts_with?(suggestion, "Pleroma.")
|
||||
end)
|
||||
end
|
||||
|
||||
test "atoms in suggestions with leading `:`" do
|
||||
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
|
||||
%{suggestions: suggestions} = Enum.at(children, 4)
|
||||
assert Enum.at(suggestions, 0) == ":atom"
|
||||
assert Enum.at(suggestions, 1) == "Pleroma.Upload"
|
||||
assert Enum.at(suggestions, 2) == {":tuple", "string", 8080}
|
||||
assert Enum.at(suggestions, 3) == [":atom", "Pleroma.Upload", {":atom", "Pleroma.Upload"}]
|
||||
|
||||
%{suggestions: suggestions} = Enum.at(children, 6)
|
||||
assert Enum.at(suggestions, 0) == ":always"
|
||||
assert Enum.at(suggestions, 1) == ":never"
|
||||
assert Enum.at(suggestions, 2) == ":if_available"
|
||||
end
|
||||
|
||||
test "group, key as string in main desc" do
|
||||
descriptions = Generator.convert_to_strings(@descriptions)
|
||||
desc = Enum.at(descriptions, 3)
|
||||
assert desc[:group] == "Some string group"
|
||||
assert desc[:key] == "Some string key"
|
||||
end
|
||||
|
||||
test "key as string subchild" do
|
||||
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
|
||||
child = Enum.at(children, 7)
|
||||
assert child[:key] == "application/xml"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue