1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

pleroma_ctl: Run mix tasks using rpc instead of eval

This patch changes pleroma_ctl to call into a running instance instead of spinning up
a new one for mix task execution. This significantly decreases the time needed
for mix task execution (on my machine for `pleroma_ctl user set rin --no-admin`
the difference is 0.2s vs 4.2s) and allows mix tasks to affect the
instance context, for example, this allows to clear the cache after user
deletion
This commit is contained in:
rinpatch 2019-06-18 00:17:47 +03:00
parent 49a49d3763
commit 448d739b25

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# XXX: This should be removed when elixir's releases get custom command support # XXX: This should be removed when elixir's releases get custom command support
if [ -z "$1" ] || [ "$1" = "help" ]; then if [ -z "$1" ] || [ "$1" = "help" ]; then
echo "Usage: $(basename "$0") COMMAND [ARGS] echo "Usage: $(basename "$0") COMMAND [ARGS]
The known commands are: The known commands are:
@ -11,9 +11,16 @@ if [ -z "$1" ] || [ "$1" = "help" ]; then
and any mix tasks under Pleroma namespace, for example \`mix pleroma.user COMMAND\` is and any mix tasks under Pleroma namespace, for example \`mix pleroma.user COMMAND\` is
equivalent to \`$(basename "$0") user COMMAND\` equivalent to \`$(basename "$0") user COMMAND\`
By default pleroma_ctl will try calling into a running instance to execute non migration-related commands,
if for some reason this is undesired, set PLEROMA_CTL_RPC_DISABLED environment variable
" "
else else
SCRIPT=$(readlink -f "$0") SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTPATH=$(dirname "$SCRIPT")
"$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run("'"$*"'")' if [ "$1" = "migrate" ] || [ "$1" = "rollback" ] || [ "$1" = "create" ] || [ -n "$PLEROMA_CTL_RPC_DISABLED" ]; then
"$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run("'"$*"'")'
else
"$SCRIPTPATH"/pleroma rpc 'Pleroma.ReleaseTasks.run("'"$*"'")'
fi
fi fi