Domanda

As the title says, I've been trying to set up a gerrit (2.6.1) server on my OS X box (Mountain Lion). Everything works fine but I can't get it to start automatically on boot.

Ideally, I want it to start as part of launchd using a plist file, but I can't seem to find much information about it. Any experts out there who can help me make gerrit start automatically on boot?

I was able to start apache/mysql using plist files, so I also have make sure gerrit starts after these as well. Thanks!

È stato utile?

Soluzione

Just managed to get it up and running under OSX Yosemite (10.10).

First of all, I gave the user I run gerrit with all the rights on the directory that gerrit is installed to /etc/gerrit2 for me. That, and I made the $GERRIT_HOME/bin/gerrit.sh executable. After this, you should be able to start gerrit from the user you want gerrit to run under with $GERRIT_HOME/bin/gerrit.sh start.

Then to make it launch during system boot create a launchd plist in /Library/LaunchDaemons(I named it com.gerrit.codereview.plist. Make sure that it has the correct permissions sudo chown root /Library/LaunchDaemons/com.gerrit.codereview.plist and sudo chmod -rw-r--r-- /Library/LaunchDaemons/com.gerrit.coderview.plist.

After that, ensure that the com.gerrit.codereview.plist looks something like this:

<?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>Label</key>
    <string>com.gerrit.codereview</string>
    <key>ProgramArguments</key>
    <array>
        <string>$GERRIT_HOME/bin/gerrit.sh</string>
        <string>start</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>$USER_TO_RUN_GERRIT_WITH</string>
    <key>WorkingDirectory</key>
    <string>$GERRIT_HOME</string>
    <key>StandardOutPath</key>
    <string>$GERRIT_HOME/logs/error_log</string>
    <key>StandardErrorPath</key>
    <string>$GERRIT_HOME/logs/error_log</string>
    <key>AbandonProcessGroup</key>
    <true/>
</dict>
</plist>

Replace all the variables with paths that match your configuration. If you want Gerrit to run as root you can omit the Username key entirely.

Then verify that the launchd configuration works by loading it sudo launhctl load /Library/LaunchDaemons/com.gerrit.codereview.plist and starting it sudo launchctl start com.gerrit.codereview. After doing this gerrit should be running and accessible via its web interface.

Altri suggerimenti

So far the best solution I was able to come up with was this, which does the job:

  1. Create a wrapper script:

    /opt/gerrit2/bin/gerrit.sh start

  2. Put a .command extension to the wrapper script - "start_gerrit.command" and make it executable

  3. In System Preferences -> User & Groups -> Login Items, add the wrapper script.

Now gerrit starts automatically whenever I log in.

I really wanted to make it run at system start-up using launchd plist, but I couldn't get it to work. Also, if I just do "sudo gerrit.sh start", it always ends up taking me to root prompt for some reason, which I have to "exit" out of:

Mac:~ me$ sudo /opt/gerrit2/bin/gerrit.sh start
Starting Gerrit Code Review: Mac:~ root# 
Mac:~ root# 
Mac:~ root# exit
logout
FAILED
Mac:~ me$ 

If someone has a better solution, please share, thanks!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top