mineshaftgap / d4m-nfs

Docker for Mac with NFS for performance improvements over osxfs
296 stars 26 forks source link

Make d4m-nfs.sh autorun at startup? #28

Closed vinta closed 7 years ago

vinta commented 7 years ago

Is it possible to make d4m-nfs.sh autorun at startup?

I created ~/Library/LaunchAgents/local.d4m-nfs:

<?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>local.d4m-nfs</string>
   <key>Program</key>
   <string>/usr/local/d4m-nfs/d4m-nfs.sh</string>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

then run launchctl start local.d4m-nfs.

It didn't work, any idea?

if-kyle commented 7 years ago

Not familiar with mac start up scripts. My guess would be that possibly Docker.app is maybe not already started when the autorun starts d4m.

We wrap our docker commands into simplified docker-compose commands that do several other things, like check that Docker is running, start d4m, and then start the proper containers for our developers local systems.

You can get a feel for it here.

https://github.com/if-fulcrum/fulcrum/blob/master/bin/lib/fulcrum#L74

vinta commented 7 years ago

I solved the problem perfectly by using this configuration:

<?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>local.d4m-nfs</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
    </dict>
    <key>ProgramArguments</key>
    <array>
        <string>sudo</string>
        <string>-u</string>
        <string>YOUR_USERNAME</string>
        <string>/usr/local/d4m-nfs/d4m-nfs.sh</string>
        <string>-q</string>
    </array>
    <key>StandardOutPath</key>
    <string>/tmp/local.d4m-nfs.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/local.d4m-nfs.log</string>
    <key>ExitTimeOut</key>
    <integer>60</integer>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>