Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
3a1e810a
Commit
3a1e810a
authored
May 21, 2020
by
Ivan Tashkinov
Browse files
[
#2497
] Customized `exexec` launch to support root operation (currently required by Gitlab CI).
parent
610343ed
Pipeline
#26218
failed with stages
in 12 minutes and 47 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
3a1e810a
...
...
@@ -6,6 +6,7 @@ variables: &global_variables
POSTGRES_PASSWORD
:
postgres
DB_HOST
:
postgres
MIX_ENV
:
test
USER
:
root
cache
:
&global_cache_policy
key
:
${CI_COMMIT_REF_SLUG}
...
...
config/config.exs
View file @
3a1e810a
...
...
@@ -681,6 +681,10 @@
config
:pleroma
,
Pleroma
.
Web
.
ApiSpec
.
CastAndValidate
,
strict:
false
config
:pleroma
,
:exexec
,
root_mode:
false
,
options:
%{}
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config
"
#{
Mix
.
env
()
}
.exs"
lib/pleroma/exec.ex
0 → 100644
View file @
3a1e810a
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma
.
Exec
do
@moduledoc
"Pleroma wrapper around Exexec commands."
alias
Pleroma
.
Config
def
ensure_started
(
options_overrides
\\
%{})
do
options
=
if
Config
.
get
([
:exexec
,
:root_mode
])
||
System
.
get_env
(
"USER"
)
==
"root"
do
# Note: running as `root` is discouraged (yet Gitlab CI does that by default)
%{
root:
true
,
user:
"root"
,
limit_users:
[
"root"
]}
else
%{}
end
options
=
options
|>
Map
.
merge
(
Config
.
get
([
:exexec
,
:options
],
%{}))
|>
Map
.
merge
(
options_overrides
)
with
{
:error
,
{
:already_started
,
pid
}}
<-
Exexec
.
start
(
options
)
do
{
:ok
,
pid
}
end
end
def
run
(
cmd
,
options
\\
%{})
do
ensure_started
()
Exexec
.
run
(
cmd
,
options
)
end
def
cmd
(
cmd
,
options
\\
%{})
do
options
=
Map
.
merge
(%{
sync:
true
,
stdout:
true
},
options
)
run
(
cmd
,
options
)
end
end
lib/pleroma/helpers/media_helper.ex
View file @
3a1e810a
...
...
@@ -7,8 +7,6 @@ defmodule Pleroma.Helpers.MediaHelper do
Handles common media-related operations.
"""
@ffmpeg_opts
[{
:sync
,
true
},
{
:stdout
,
true
}]
def
ffmpeg_resize_remote
(
uri
,
%{
max_width:
max_width
,
max_height:
max_height
})
do
cmd
=
~s""
"
curl -L "
#{uri}" |
...
...
@@ -20,7 +18,7 @@ def ffmpeg_resize_remote(uri, %{max_width: max_width, max_height: max_height}) d
cat
"""
with {:ok, [stdout: stdout_list]} <-
Exexec.run(cmd, @ffmpeg_opts
) do
with {:ok, [stdout: stdout_list]} <-
Pleroma.Exec.cmd(cmd
) do
{:ok, Enum.join(stdout_list)}
end
end
...
...
mix.exs
View file @
3a1e810a
...
...
@@ -197,7 +197,8 @@ defp deps do
ref:
"e0f16822d578866e186a0974d65ad58cddc1e2ab"
},
{
:mox
,
"~> 0.5"
,
only:
:test
},
{
:restarter
,
path:
"./restarter"
},
{
:exexec
,
"~> 0.2"
},
# Note: `runtime: true` for :exexec makes CI fail due to `root` user (see Pleroma.Exec)
{
:exexec
,
"~> 0.2"
,
runtime:
false
},
{
:open_api_spex
,
git:
"https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git"
,
ref:
"f296ac0924ba3cf79c7a588c4c252889df4c2edd"
}
...
...
test/exec_test.exs
0 → 100644
View file @
3a1e810a
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma
.
ExecTest
do
alias
Pleroma
.
Exec
use
Pleroma
.
DataCase
test
"it starts"
do
assert
{
:ok
,
_
}
=
Exec
.
ensure_started
()
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment