当前位置: 首页 > news >正文

Running Redis as a User Daemon on OSX With Launchd

为什么80%的码农都做不了架构师?>>>   hot3.png

If you’re developing on the mac using redis and want it to start automatically on boot, you’ll want to leverage the OSX launchd system to run it as a User Daemon. A User Daemon is a non-gui program that runs in the background as part of the system. It isn’t associated with your user account. If you only want redis to launch when a particular user logs in, you’ll want to make a User Agent instead.

From the command line, create a plist file as root in the /Library/LaunchDaemons directory with your favorite text editor:

sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist

Paste in the following contents and modify it to point it to wherever you’ve got redis-server installed and optionally pass the location of a config file to it (delete the redis.conf line if you’re not using one):

<?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>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>

Make sure that you actually have a redis.conf file at the location above. If you’ve installed it with homebrewthat should be the correct location.

You’ll then need to load the file (one time) into launchd with launchctl:

sudo launchctl load /Library/LaunchDaemons/io.redis.redis-server.plist

Redis will now automatically be started after every boot. You can manually start it without rebooting with:

sudo launchctl start io.redis.redis-server

You can also shut down the server with

sudo launchctl stop io.redis.redis-server

Or you could add these aliases to your bash/zsh rc file:

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

If you’re having some sort of error (or just want to watch the logs), you can just fire up Console.app to watch the redis logs to see what’s going on.

转载于:https://my.oschina.net/surjur/blog/487820

相关文章:

  • webx5 复选框的显示
  • Linux驱动总结3- unlocked_ioctl和堵塞(waitqueue)读写函数的实现 【转】
  • android makefile 小结
  • SqlServerException:拒绝对表对象的select,insert权限解决(新建账号导致的问题)
  • [知识点]C++中的运算符
  • 六间房 繁星 酷我 来疯 秀吧 新浪秀 直播播放器 Live 1.2
  • 组合条件测试
  • VCE文件的另类打开方式
  • 织梦DEDECMS {dede:field name='position'/}标签增加其它属性的
  • 各种链接
  • hdu 1316 How Many Fibs?
  • jboss7 添加虚拟目录 上传文件路径
  • OSChina 周六乱弹 —— 流氓软件是这样耍流氓的
  • 修改mysql用户密码
  • JavaWeb项目中WEB-INF目录下class文件自动生成以及显示
  • 5分钟即可掌握的前端高效利器:JavaScript 策略模式
  • android高仿小视频、应用锁、3种存储库、QQ小红点动画、仿支付宝图表等源码...
  • CSS魔法堂:Absolute Positioning就这个样
  • eclipse(luna)创建web工程
  • FineReport中如何实现自动滚屏效果
  • javascript数组去重/查找/插入/删除
  • Java教程_软件开发基础
  • jquery cookie
  • js中的正则表达式入门
  • opencv python Meanshift 和 Camshift
  • SpiderData 2019年2月13日 DApp数据排行榜
  • vue-cli3搭建项目
  • 不上全站https的网站你们就等着被恶心死吧
  • 猴子数据域名防封接口降低小说被封的风险
  • 精彩代码 vue.js
  • 为视图添加丝滑的水波纹
  • 系统认识JavaScript正则表达式
  • 用element的upload组件实现多图片上传和压缩
  • 分布式关系型数据库服务 DRDS 支持显示的 Prepare 及逻辑库锁功能等多项能力 ...
  • 摩拜创始人胡玮炜也彻底离开了,共享单车行业还有未来吗? ...
  • ​​​​​​​GitLab 之 GitLab-Runner 安装,配置与问题汇总
  • ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
  • #Z2294. 打印树的直径
  • (编程语言界的丐帮 C#).NET MD5 HASH 哈希 加密 与JAVA 互通
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)ssm高校实验室 毕业设计 800008
  • (牛客腾讯思维编程题)编码编码分组打印下标题目分析
  • (强烈推荐)移动端音视频从零到上手(上)
  • (三分钟了解debug)SLAM研究方向-Debug总结
  • (十六)串口UART
  • (五)IO流之ByteArrayInput/OutputStream
  • (一)80c52学习之旅-起始篇
  • (转)如何上传第三方jar包至Maven私服让maven项目可以使用第三方jar包
  • .bat批处理(十一):替换字符串中包含百分号%的子串
  • .net连接oracle数据库
  • .NET设计模式(2):单件模式(Singleton Pattern)
  • .NET文档生成工具ADB使用图文教程
  • @NestedConfigurationProperty 注解用法
  • @RequestBody与@ModelAttribute
  • @Tag和@Operation标签失效问题。SpringDoc 2.2.0(OpenApi 3)和Spring Boot 3.1.1集成