Post

맥에서 Redis 서버데몬으로 실행하기

  • Plist 생성하기

    • plist 파일 생성

      1
      
      # sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist
      
    • 파일 작성

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "<a href="http://www.apple.com/DTDs/PropertyList-1.0.dtd" data-mce-href="http://www.apple.com/DTDs/PropertyList-1.0.dtd">http://www.apple.com/DTDs/PropertyList-1.0.dtd</a>">
      <plist version="1.0">
      <dict>
          <key>Label</key>
          <string>io.redis.redis-server</string>
          <key>ProgramArguments</key>
          <array>
              <string>/usr/local/bin/redis-server</string>
              <string>/usr/local/etc/redis.conf</string>
          </array>
          <key>RunAtLoad</key>
          <true/>
      </dict>
      </plist>
      
  • Homebrew로 설치했을 경우에는 redis.conf의 위치는 /usr/local/etc/redis.conf 이다.

  • launchctl에 등록하기

    • 재부팅할때마다 자동으로 Redis 서버가 실행된다.

      1
      
      # sudo launchctl load /Library/LaunchDaemons/io.redis.redis-server.plist
      
    • 재부팅없이 수동을 실행

      1
      
      # sudo launchctl start io.redis.redis-server
      
    • 수동으로 정지하기

      1
      
      # sudo launchctl stop io.redis.redis-server
      
  • 사용자 .profilealias로 등록하기

    1
    2
    
    # alias redisstart='sudo launchctl start io.redis.redis-server'
    # alias redisstop='sudo launchctl stop io.redis.redis-server'
    

참고사이트

  • http://naleid.com/blog/2011/03/05/running-redis-as-a-user-daemon-on-osx-with-launchd/
This post is licensed under CC BY 4.0 by the author.