Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions templates/redis.socketed.template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
run:
- file:
path: /etc/service/redis/run
chmod: "+x"
contents: |
#!/bin/sh
exec 2>&1
exec thpoff chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
- file:
path: /etc/service/redis/log/run
chmod: "+x"
contents: |
#!/bin/sh
mkdir -p /var/log/redis
exec svlogd /var/log/redis
- file:
path: /etc/runit/3.d/10-redis
chmod: "+x"
contents: |
#!/bin/bash
sv stop redis
- replace:
filename: "/etc/redis/redis.conf"
from: "port 6379"
to: "port 0"
- replace:
filename: "/etc/redis/redis.conf"
from: "# unixsocket /tmp/redis.sock"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from: "# unixsocket /tmp/redis.sock"
from: /^# unixsocket .*$/

to: "unixsocket /shared/tmp/redis.sock"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/shared/tmp is only writable by discourse user by default, so the UNIX socket needs to be created elsewhere:

Suggested change
to: "unixsocket /shared/tmp/redis.sock"
to: "unixsocket /shared/redis_data/redis.sock"

To align with PostgreSQL, redis_run could be added as new directory for the socket.

- replace:
filename: "/etc/redis/redis.conf"
from: "# unixsocketperm 700"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from: "# unixsocketperm 700"
from: /^# unixsocketperm .*$/

to: "unixsocketperm 777"
- replace:
filename: "/etc/redis/redis.conf"
from: /^pidfile.*$/
to: ""

- exec:
cmd:
- install -d -m 0755 -o redis -g redis /shared/redis_data
Comment on lines +40 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd:
- install -d -m 0755 -o redis -g redis /shared/redis_data
cmd: install -d -m 0755 -o redis -g redis /shared/redis_data


- replace:
filename: "/etc/redis/redis.conf"
from: /^logfile.*$/
to: 'logfile ""'

- replace:
filename: "/etc/redis/redis.conf"
from: /^bind .*$/
to: ""

- replace:
filename: "/etc/redis/redis.conf"
from: /^dir .*$/
to: "dir /shared/redis_data"

- replace:
filename: "/etc/redis/redis.conf"
from: /^protected-mode yes/
to: "protected-mode no"

Comment on lines +57 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protected mode allows UNIX socket connections, so leave this untouched:

Suggested change
- replace:
filename: "/etc/redis/redis.conf"
from: /^protected-mode yes/
to: "protected-mode no"

- exec:
cmd: echo redis installed
hook: redis
- exec: cat /etc/redis/redis.conf | grep logfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid

Suggested change
- exec: cat /etc/redis/redis.conf | grep logfile
- exec: grep logfile /etc/redis/redis.conf


- exec:
background: true
cmd: exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf

- exec: sleep 10

# we can not migrate without redis, launch it if needed
hooks:
before_code:
- exec:
background: true
cmd: exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
after_code:
- replace:
filename: /etc/service/unicorn/run
from: "# redis"
to: sv start redis || exit 1