-
Notifications
You must be signed in to change notification settings - Fork 257
Setup
On Mac OS X, you can set rdm can be run on demand, on your behalf, by
launchd, and have it exit cleanly after a period of inactivity. The easiest
way to do this is with Homebrew:
brew services start rtags
You can also do it manually using the following steps:
- Create a file, e.g., in emacs, with the following contents:
<?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.andersbakken.rtags.agent</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string>$RDM -v --launchd --inactivity-timeout 300 --log-file ~/Library/Logs/rtags.launchd.log</string> </array> <key>Sockets</key> <dict> <key>Listener</key> <dict> <key>SockPathName</key> <string>$HOME/.rdm</string> </dict> </dict> </dict> </plist>
- Replace
$HOMEwith the absolute path to your home folder. Replace$RDMwith the path to your copy ofrdm, and add any command line parameters you might usually use.(The
SockPathNameentry relates to the name of the domain socket thatrdmuses. The settings above are for the default value; if your command line options direct it to use some other name, please modify it to suit. Unfortunatelylaunchd’s configuration files are a bit naff, so you’ll have to repeat yourself.) - Save the result as
~/Library/LaunchAgents/com.andersbakken.rtags.agent.plist. - Run the following command from the terminal:
launchctl load ~/Library/LaunchAgents/com.andersbakken.rtags.agent.plist(This will happen automatically next time you log back in.)
- Try using RTags, and you should find
rdmwill spring into life!
-
rdmwill automatically quit after 5 minutes of inactivity (this is what the--inactivity-timeout 300command line option is for), so it won’t stick around hogging memory. Butlaunchdwill still be watching its socket for activity, and will relaunch it if necessary. - You can watch
launchd’s logging by tailing~/Library/Logs/rtags.launchd.log.
On GNU/Linux distributions based on the systemd service manager, rdm can
also be socket acivated.
- Add the following to
~/.config/systemd/user/rdm.socket[Unit] Description=RTags daemon socket [Socket] ListenStream=%t/rdm.socket [Install] WantedBy=default.target - Add the following to
~/.config/systemd/user/rdm.service[Unit] Description=RTags daemon Requires=rdm.socket [Service] Type=simple ExecStart=$RDM -v --inactivity-timeout 300 --log-flush ExecStartPost=/bin/sh -c "echo +19 > /proc/$MAINPID/autogroup" Nice=19 CPUSchedulingPolicy=idle - Replace
$RDMwith the path to your copy ofrdm, and add any command line parameters you might usually use.You have to use absolute paths here.
%his expanded to your home directory. Environment variables are not expanded inside strings. - Run the following command from the terminal:
systemctl --user enable rdm.socket systemctl --user start rdm.socketSystemdwill create therdmsocket automatically.Note that user level systemd does not work on RHEL derivatives. See here for more info: https://bugs.centos.org/view.php?id=8767
If you prefer using SystemV something like this could be used:
#!/bin/bash
#
# chkconfig: 35 90 12
# description: Foo server
#
# Get function from functions library
. /etc/init.d/functions
# Start the service FOO
start() {
initlog -c "echo -n Starting FOO server: "
/path/to/FOO &
### Create the lock file ###
touch /var/lock/subsys/FOO
success $"FOO server startup"
echo
}
# Restart the service FOO
stop() {
initlog -c "echo -n Stopping FOO server: "
killproc FOO
### Now, delete the lock file ###
rm -f /var/lock/subsys/FOO
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status FOO
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
You can specify default options for rdm by putting the options in the file
/.rdmrc. Just put the options, one per line, in the configuration
file. Lines starting with ‘#’ are ignored.
For example:
# This is a comment
--data-dir=~/my/rdm/data/dir
--start-suspended