preloader

Install OrientdDB As a Service On A Mac

images/orientdb_logo_mid.png
By J. Toman / on 20 Jan, 2019

OrientDB is a multi-model database that combines the best of a document database and a graph database. I’ve played around with it off and on, but one difficulty is that I’ve always had to restart the server manually whenever I reboot my Mac. Being an old Linux guy, steeped in chron and /etc/init.d , I’ve never taken the time to learn Apple’s launchd system or the plist files they depend on. Until now. Turns out they’re pretty simple. The Orientdb documentation covers basic installation of the database pretty well so I won’t repeat that here. Instead I’ll detail the part I couldn’t find, installing the database as a service which starts on system boot. Most of this is cribbed from this article on installing MongoDB as a service on OS X, so thank you Mr. Ali Al Dallal for that.

I usually install third party tools that don’t have any installer in /usr/local , and being an old Linux guy I usually decompress the versioned directory from the tarball in /usr/local and then create a soft link to it, so my path the OrienDB install is /usr/local/orientdb . The plist I used is available as a GIthub gist here . It goes in /Library/LaunchDaemons, named, for instance org.orientdb.orientdb.plist . As you can see in the gist, stdout and stderr are redirected to log files /var/log/orientdb/sout.log and /var/log/orientdb/serror.log respectively, so we need to create that directory :

sudo mkdir /var/log/orientdb

and create the stubbed log files

sudo touch /var/log/orientdb/sout.log
sudo touch /var/log/orientdb/serror.log

Finally we need to grant ownership of the plist file to root:wheel

sudo chown root:wheel /Library/LaunchDaemon/org.orientdb.orientdb.plist

And then start the server running

sudo launchctl load /Library/LaunchDaemon/org.orientdb.orientdb.plist
sudo launchctl start org.orientdb.orientdb

And your server should be up and running every time you reboot your system.

Just for completeness, stopping your server is what you would expect:

sudo launchctl stop org.orientdb.orientdb

As is removing it from the list of things that start at boot time

sudo launchctl unload /Library/LaunchDaemon/org.orientdb.orientdb.plist

which will also stop the job, if running.