OSX为节点永久进程启动了plist [英] OSX launchd plist for node forever process

查看:115
本文介绍了OSX为节点永久进程启动了plist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的节点服务器编写launchd.plist文件.我一直在使用它来运行节点服务器.我希望服务器在启动时启动.我还要等待mongodb启动的plist首先运行.

I am trying to write a launchd.plist file for my node server. I am using forever to run my node server. I would like the server to start on boot. I would also like to wait for the mongodb launchd plist to run first.

我使用自制软件安装了mongobb,它已经带有launchd.plist.我执行了以下操作:

I installed mongobb using homebrew and it came with a launchd.plist already. I have executed the following:

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

mongodb的plist是:

plist for mongodb is:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.mongodb</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/mongodb/mongod</string>
    <string>run</string>
    <string>--config</string>
    <string>/usr/local/etc/mongod.conf</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <false/>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/var/log/mongodb/output.log</string>
  <key>StandardOutPath</key>
  <string>/usr/local/var/log/mongodb/output.log</string>
  <key>HardResourceLimits</key>
  <dict>
    <key>NumberOfFiles</key>
    <integer>1024</integer>
  </dict>
  <key>SoftResourceLimits</key>
  <dict>
    <key>NumberOfFiles</key>
    <integer>1024</integer>
  </dict>
</dict>
</plist>

如果我关闭计算机并重新启动,则mongodb会正常启动.

If I shutdown the computer and restart mongodb fires up as it should.

但是我的节点服务器没有启动.有什么想法吗?

However my node server is not starting. Any ideas?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>KeepAlive</key>
        <dict>
            <key>SuccessfulExit</key>
            <false/>
        </dict>
        <key>Label</key>
        <string>com.test.app</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/bin/forever</string>
            <string>-a</string>
            <string>-l</string>
            <string>/var/log/app/app.log</string>
            <string>-e</string>
            <string>/var/log/app/app_error.log</string>
            <string>/data/server/app.js</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>3600</integer>
    </dict>
</plist>

写入日志文件,我看到了:

writing to log file and I see this:

env:节点:没有这样的文件或目录

env: node: No such file or directory

我认为这意味着找不到节点二进制文件.我可以回显$ PATH,并且/usr/local/bin在我的路径中.我可以从终端启动节点.想法?

I think this means that the node binary cannot be found. I can echo $PATH and /usr/local/bin is in my path. I can start node from the terminal. Ideas?

推荐答案

添加环境变量对我有用.

Add environment Variables worked for me.

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/usr/local/bin/:$PATH</string>
</dict>

您可能还需要将WorkingDirectory添加到您的节点应用程序.

You may also need to add WorkingDirectory to your node app.

<key>WorkingDirectory</key>
<string>path/to/your/node/app</string>

这篇关于OSX为节点永久进程启动了plist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆