Question

I have a capistrano script that can control my redis server. Here's the task in question:

  %w[start stop restart].each do |cmd|
    desc "#{cmd}s redis-server"
    task cmd, :roles => :app do
      run "#{sudo} /etc/init.d/redis-server #{cmd}"
    end
  end

When I run this (deploying to a local vagrant VM) it says it's starts successfully:

    > cap local redis:start


    triggering load callbacks
  * executing `local'
Deploying branch master
    triggering start callbacks for `redis:start'
  * executing `multistage:ensure'
  * executing `redis:start'
  * executing "sudo -p 'sudo password: ' /etc/init.d/redis-server start"
    servers: ["192.168.33.10"]
Password: 
    [192.168.33.10] executing command
 ** [out :: 192.168.33.10] Starting redis-server:
 ** [out :: 192.168.33.10] redis-server.
    command finished in 2054ms

However redis-server is not running when I ssh in. It works if I start it manually:

> sudo /etc/init.d/redis-server start

And I get the same output as above, only this time the process stays running.

Looking at the logs at /var/log/redis/redis.log and the file is empty.

Any ideas what I'm doing wrong? I start up other services like this (nginx, unicorn, mysql, etc) and those are working fine.

Was it helpful?

Solution

I believe the redis process is ending once the ssh connection is terminated.

Try adding nohup to your script:

run "#{sudo} nohup /etc/init.d/redis-server #{cmd}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top