命令“sudo service supervisord start”和“sudo supervisord”之间有什么区别?

时间:2014-11-10 22:54:49

标签: python service supervisord

我正在尝试编写一个配置文件来运行supervisord并对某些任务进行守护。现在我有一个虚拟程序,它回应cli“你好”,以便我使用我的conf文件知道supervisord。有两个命令我试图启动supervisord,一个使用我的配置文件,另一个无法使用我的配置文件,我不知道为什么。

失败的命令:

sudo service supervisord start --configuration=/current/director/path/supervisord.conf --nodaemon=true

结果:

 Starting supervisor: supervisord.

有效的命令:

 sudo supervisord --configuration=/current/directory/path/supervisord.conf

结果:

 2014-11-10 22:46:07,332 DEBG fd 6 closed, stopped monitoring <POutputDispatcher at 140621301889000 for <Subprocess at 140621301888424 with name flower in state STARTING> (stdout)>
 2014-11-10 22:46:07,333 DEBG fd 8 closed, stopped monitoring <POutputDispatcher at 140621301954896 for <Subprocess at 140621301888424 with name flower in state STARTING> (stderr)>
 2014-11-10 22:46:07,334 INFO exited: flower (exit status 1; not expected)
 2014-11-10 22:46:07,335 DEBG received SIGCLD indicating a child quit
 2014-11-10 22:46:08,336 INFO gave up: flower entered FATAL state, too many start retries too quickly
 2014-11-10 22:46:28,858 WARN received SIGHUP indicating restart request
 2014-11-10 22:47:03,170 CRIT Supervisor running as root (no user in config file)
 2014-11-10 22:47:03,175 INFO supervisord started with pid 28776
 2014-11-10 22:47:04,178 INFO spawned: 'flower' with pid 28779
 2014-11-10 22:47:04,185 DEBG 'flower' stdout output:
 hello

第二个结果死的事实很好,因为我希望它在回显“hello”之后至少我知道它在指定的路径中使用conf文件。我很困惑为什么第一个命令不使用我的配置文件,两者之间有什么区别?

supervisord.conf:

[supervisord]
logfile=/logfile/user/has/access/to/supervisord.log
loglevel=debug

[program:flower]
command=echo hello
process_name=%(program_name)s
autostart=True
autorestart=True

1 个答案:

答案 0 :(得分:1)

简短版: 它完全忽略了您提供的参数。

更长版本: 您指定的第一个命令sudo service supervisord start --configuration=/current/director/path/supervisord.conf --nodaemon=true不是为了在您提供的方法中获取参数。相反,service采用服务的名称(通常在/etc/init.d/中找到)和操作。可以传递其他参数,这些参数可能因操作系统而异。有关操作系统的详细信息,请参阅手册页(man service)。

要执行的操作通常是以下之一:

  • 启动
  • 停止
  • 重新开始
  • 重载
  • 状态

使用服务命令的正确方法是sudo service supervisord start。这将使用位于/etc/default/etc/sysconfig/etc/etc的根目录中的某个位置的配置文件。位置将有所不同,具体取决于您使用的特定Linux发行版。

要查找有关实际发生情况的详细信息,导致主管出现并退出,请检查/var/log,明确查看文件/var/log/messages(如果存在)或/var/log/syslog,或者名为supervisord的文件或子目录。