2

I had to install an older version of Elasticsearch (2.3.3) from source. The binary is located in /opt/local/elasticsearch-2.3.3/bin/ I created the following file

/Library/LaunchDaemons/org.elasticsearch.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.elasticsearch</string>
        <key>ProgramArguments</key>
        <array>
            <string>/opt/local/elasticsearch-2.3.3/bin/elasticsearch</string>
        </array>
        <key>UserName</key>
        <string>root</string>
<!--         <key>GroupName</key>
        <string>staff</string> -->
        <key>WorkingDirectory</key>
        <string>/opt/local/elasticsearch-2.3.3/bin</string>
        <key>KeepAlive</key>
        <true/>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>

I then issue the following command:

sudo launchctl load -w /Library/LaunchDaemons/org.elasticsearch.plist

When I inquire with sudo launchctl list | grep elastic it returns org.elasticsearch. But when I check if elasticsearch is running with ps ax | grep elastic it is not running.

Is there something wrong with my .plist file?

  • Please don't do double posts and delete the identical one at stackexchange.com. – klanomath Aug 17 '17 at 2:03
1

Elasticsearch mustn't be run as root. So remove the plist from the launchd database, move the plist to /Library/LaunchAgents (or ~/Library/LaunchAgents), create /opt/local/var and modify it slightly:

<?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>EnvironmentVariables</key>
    <dict>
        <key>VAR</key>
        <string>VAL</string>
    </dict>
    <key>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>org.elasticsearch</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/local/elasticsearch-2.3.3/bin/elasticsearch</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/tmp/org.elasticsearch.stderr</string>
    <key>StandardOutPath</key>
    <string>/tmp/org.elasticsearch.stdout</string>
    <key>WorkingDirectory</key>
    <string>/opt/local/var</string>
</dict>
</plist>

Then check /opt/local/elasticsearch-2.3.3 and its subdirs for proper permissions, add EnvironmentVariables if necessary (or remove the key & dict) and load the plist.

If everything works properly you may remove StandardErrorPath and StandardOutPath and their strings.


You may also run it as daemon but with a different user then (i.e. your user name) - depends on your needs/environment.

  • ok this works when I load it manually, but it does not load on boot... – mike Aug 17 '17 at 13:53
  • just rebooting and then logging in. – mike Aug 17 '17 at 14:29
  • @mikeglaz I have no problem with this set up. Please check org.elasticsearch.stdout/stderr for errors. Probably it's a permission error in the /opt/local/elasticsearch-2.3.3 and/or the /opt/local/var path. Everyone needs full access to all subdirs. Additionally/alternatively you may move ...stdout/stderr to /opt/local/tmp. – klanomath Aug 17 '17 at 15:06
  • ok it worked, I need to change the permissions for /opt/local/var – mike Aug 17 '17 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .