【问题标题】:User job not enabled未启用用户作业
【发布时间】:2015-06-27 09:25:33
【问题描述】:

我在 ~/.init 文件夹中有一个 codetains.conf 文件

    description "Codestains"
    author "Varun Mundra"

    start on virtual-filesystems
    stop on runlevel [06]

    env PATH=/opt/www/codestains.com/current/bin:/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/bin:/us$

    env RAILS_ENV=production
    env RACK_ENV=production

    setuid ubuntu
    setgid sudo

    chdir /opt/www/codestains.com

    pre-start script
      exec >/home/ubuntu/codestains.log 2>&1
      exec /opt/www/codestains.com/current/bin/unicorn -D -c /opt/www/codestains.com/current/config/unicorn.rb $
    end script

    post-stop script
      exec kill 'cat /tmp/unicorn.codestains.pid'
    end script

我在 /etc/dbus-1/system.d/Upstart.conf` 中添加了 https://gist.github.com/bradleyayers/1660182 以启用 Upstart 用户作业 但每次我跑

    start codestains
    sudo start codestains

我得到“开始:未知工作:代码染色”。 我已经尝试了很多在线可用的东西。似乎没有任何帮助。

还有,

    init-checkconf codestains.conf

给出“文件 codetains.conf:语法正常”

【问题讨论】:

    标签: ruby-on-rails ubuntu unicorn upstart


    【解决方案1】:

    我发现了一个肯定是问题的错误;我不知道这是否是唯一的问题。我没有尝试测试它。但是,这一点:

    exec kill 'cat /tmp/unicorn.codestains.pid'

    肯定是错的,它会将字符串cat /tmp/unicorn.codestains.pid 传递给kill 命令,这不会做你想要的。

    您可能已经看过一个示例,但忽略了它们是反引号字符,这会导致 shell 执行cat /tmp/unicorn.codestains.pid,捕获其STDOUT,然后在放置反引号的位置插入结果; IOW 它将该 pid 文件的内容传递给 kill 命令。

    像这样:

    exec kill `cat /tmp/unicorn.codestains.pid`

    注意细微的不同backtick character

    哪些 shell(至少是 bash)会按照我的描述进行特殊处理:http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html (参见“命令替换”部分)

    HTH

    【讨论】:

      猜你喜欢
      • 2014-05-27
      • 1970-01-01
      • 2014-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      • 1970-01-01
      相关资源
      最近更新 更多