Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart doesn't work #432

Closed
jmuheim opened this issue Sep 8, 2016 · 5 comments
Closed

Restart doesn't work #432

jmuheim opened this issue Sep 8, 2016 · 5 comments

Comments

@jmuheim
Copy link

jmuheim commented Sep 8, 2016

I have the following deploy task:

desc "Deploys the current version to the server."
task deploy: :environment do
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'notify_rollbar'

    to :launch do
      in_path(fetch(:current_path)) do
        command %{mkdir -p tmp/}
        command %{touch tmp/restart.txt}
      end
    end
  end
end

Sadly, the file tmp/restart.txt doesn't really seem to be touched, as I have to manually touch it myself to really make Rails restart. What's wrong here?

@jmuheim
Copy link
Author

jmuheim commented Sep 8, 2016

By the way, what's the difference between on and to?

@jmuheim
Copy link
Author

jmuheim commented Sep 12, 2016

I have done it like this, now it's working:

desc "Deploys the current version to the server."
task deploy: :environment do
  deploy do
    # ...

    to :launch do
      invoke :restart
    end
  end
end

task :restart do
  queue %[echo '-----> Restarting Rails app']
  queue "touch #{deploy_to}/shared/tmp/restart.txt"
end

@jmuheim jmuheim closed this as completed Sep 12, 2016
@cameronbourgeois
Copy link

@jmuheim I was having a similar issue recently with restarting my server. The initial issue was related to the mina-unicorn gem, however I did go on to discover that it seems as though the current symlink has not yet been linked correctly before the :restart task runs.

My issue is over on the mina-unicorn gem: scarfacedeb/mina-unicorn#21

@devvmh
Copy link
Contributor

devvmh commented Sep 19, 2016

@jmuheim on is the new to, since the 1.0.x upgrade, AFAIK. I'm using this code:

task deploy: :environment do
  deploy do
    # ... lots of stuff
    on :launch do
      invoke :'passenger:restart'
    end
  end
end

namespace :passenger do
  task :restart do
    in_path(fetch(:current_path)) do
      comment 'Restarting passenger'
      command %(touch tmp/restart.txt)
    end
  end
end

I'm not sure what's different about my code & yours, but my guess is it's on vs to, and not the use of invoke... but who knows?

@cameronbourgeois
Copy link

Hey guys, it seems I fixed my issue by also moving my restart commands into a seperate task and referencing from the to :launch block.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants