Fabric和Sudo作为另一个用户 [英] Fabric and Sudo as Another User
问题描述
使用Fabric启动服务器,除我尝试启动postgresql之外,其他所有操作都很好.
Using Fabric to spin up a server, everything works great, except for my attempt to start postgresql.
sudo("/usr/lib/postgresql/9.1/bin/pg_ctl -D /mnt/ebs/postgresql/data -l /mnt/ebs/logfile start", user='postgres')
它输出服务器正在启动",但实际上并没有启动. PostgreSQL日志中什么也没有显示.
It outputs "server starting", but it doesn't actually start. Nothing shows up in the postgresql log.
如果我使用ssh并执行与用户postgres
相同的命令,它将起作用.如果我使用ssh并运行以下命令,它也可以正常工作.
If I ssh in and execute the same command as user postgres
it works. If I ssh in and run the following, it works as well.
sudo su postgres -c '/usr/lib/postgresql/9.1/bin/pg_ctl -D /mnt/ebs/postgresql/data -l /mnt/ebs/logfile start
我对用户的结构没有什么了解?还是Linux用户的工作方式?
What aren't I getting about the way fabric does users? Or the way linux users work?
推荐答案
在文档中为您的用例提供了一个章节.它与sudo无关,而与默认调用的pty设置有关.常见问题解答中的更多信息.
Here's a section in the docs for your use case. It's related not to the sudo, but to the pty settings of default calls. More info in the FAQ.
这篇关于Fabric和Sudo作为另一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!