mina-deploy / mina

Blazing fast deployer and server automation tool
https://rubygems.org/gems/mina
Other
4.35k stars 491 forks source link

I am simply trying to restart my nginx server #539

Closed staycreativedesign closed 7 years ago

staycreativedesign commented 7 years ago

There is a plugin called mina-nginx which is overkill all I am trying to do is restart my nginx after I deploy my sinatra app. I have this code

require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv'  # for rbenv support. (https://rbenv.org)
require 'mina/rvm'    # for rvm support. (https://rvm.io)

set :domain, 'dot'
set :deploy_to, 'foo'
set :repository, 'bar'
#set :repository, 'biz'
set :branch, 'master'

set :forward_agent, true     # SSH forward_agent.

# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  invoke :'rvm:use', 'ruby-2.3.1'
end

# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do
  command %{ gem install bundler }
  # command %{rbenv install 2.3.0}
end

desc "Deploys the current version to the server."
task :deploy 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 :'bundle:install'
    invoke :'deploy:cleanup'
    invoke :restart

  end

end

task :restart do
 comment "Restarting Nginx Server"
 command "sudo service nginx restart"

end

Now every time I try to run my restart command it doesn't work. It hangs on the sudo service nginx restart because it's waiting for a password to be entered by why do I need a password if I am using ssh forwarding?

d4be4st commented 7 years ago

There are a couple of ways to solve this:

  1. https://github.com/mina-deploy/mina/blob/master/docs/faq.md#--mina-hangs-after-i-type-my-password-in
  2. add sudo service nginx restart to sudoers file with NOPASSWD
  3. Why not just restart the app, why do you kill whole nginx? Most servers use tmp/restart.txt to restart just that application.