Skip to content

Commit 7cd7aec

Browse files
committed
Use Valkey by default if installed
1 parent de17c90 commit 7cd7aec

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

lib/ronin/app/cli.rb

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ def run
104104
Dir.chdir(ROOT)
105105

106106
begin
107-
unless is_redis_running?
108-
log_info "Starting Redis server ..."
109-
pids << start_redis
110-
sleep 1
107+
if is_valkey_installed?
108+
unless is_valkey_running?
109+
log_info "Starting Valkey server ..."
110+
pids << start_valkey
111+
sleep 1
112+
end
113+
else
114+
unless is_redis_running?
115+
log_info "Starting Redis server ..."
116+
pids << start_redis
117+
sleep 1
118+
end
111119
end
112120

113121
# start the web server process
@@ -142,6 +150,26 @@ def is_redis_running?
142150
!`pgrep redis-server`.empty?
143151
end
144152

153+
#
154+
# Determines if the Valkey server is running.
155+
#
156+
# @return [Boolean]
157+
# Specifies whether the `valkey-server` process is running or not.
158+
#
159+
def is_valkey_running?
160+
!`pgrep valkey-server`.empty?
161+
end
162+
163+
#
164+
# Determines if the Valkey server is installed.
165+
#
166+
# @return [Boolean]
167+
# Specifies whether the `valkey-server` is installed or not.
168+
#
169+
def is_valkey_installed?
170+
system("command -v redis-server > /dev/null 2>&1")
171+
end
172+
145173
#
146174
# Starts the Redis server.
147175
#
@@ -152,6 +180,16 @@ def start_redis
152180
Process.spawn('redis-server')
153181
end
154182

183+
#
184+
# Starts the Valkey server.
185+
#
186+
# @return [Integer]
187+
# The PID of the `valkey-server` process.
188+
#
189+
def start_valkey
190+
Process.spawn('valkey-server')
191+
end
192+
155193
#
156194
# Starts the web server process.
157195
#

scripts/setup

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ function auto_install_git()
217217
fi
218218
}
219219

220+
#
221+
# Installs redis-server if valkey-server is not installed.
222+
#
223+
function auto_install_datastore()
224+
{
225+
if command -v valkey-server >/dev/null; then
226+
log "Skipping redis installation, valkey is already installed."
227+
else
228+
auto_install_redis
229+
fi
230+
}
231+
220232
#
221233
# Installs ruby via homebrew and configures it.
222234
#
@@ -418,7 +430,7 @@ function parse_options()
418430

419431
parse_options "$@" || exit $?
420432
detect_system
421-
auto_install_redis
433+
auto_install_datastore
422434
auto_install_git
423435
auto_install_gcc
424436
auto_install_gpp

0 commit comments

Comments
 (0)