/var/discourse/launcher enter app
rails c
UserDestroyer.new(Discourse.system_user).destroy(User.find_by_username_or_email("user@example.com"), delete_posts: false)
我有一个包含大量用户名的文本文件,需要从中移除这些用户。手动执行此操作是不现实的。我尝试将删除命令封装在一个 Bash 脚本中。但在执行 launcher app 子命令的 rails c 时,Redis 连接失败:
/var/discourse/launcher run app "echo \"User.find_by_username_or_email('user@example.com')\" | rails c"
Failed to report error: Error connecting to Redis on localhost:6379 (Errno::EADDRNOTAVAIL) 2 Error connecting to Redis on localhost:6379 (Errno::EADDRNOTAVAIL) subscribe failed, reconnecting in 1 second.
然而,当我使用 export 比较 launcher enter app 和 launcher run app 的环境变量时,它们看起来几乎完全相同。我遗漏了什么?launcher run 从 / 目录启动,而 launcher enter 直接进入 /var/www/discourse。在执行 rails 之前使用 cd 也无济于事。