Skip to content

Commit

Permalink
add gunicorn restart script
Browse files Browse the repository at this point in the history
  • Loading branch information
maelys-buhler committed Apr 26, 2024
1 parent 9d2a6d1 commit cea7224
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 8 additions & 6 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,26 @@
end
end

after 'deploy:publishing', 'gunicorn:restart'
after 'deploy:publishing', 'nginx:restart'

namespace :gunicorn do
namespace :nginx do
desc 'Restart application'
task :restart do
on roles(:web) do |h|
execute :sudo, 'systemctl restart gunicorn'
execute :sudo, 'service nginx restart'
end
end
end

after 'deploy:publishing', 'nginx:restart'
after 'deploy:publishing', 'gunicorn:restart'

namespace :nginx do
namespace :gunicorn do
desc 'Restart application'
task :restart do
on roles(:web) do |h|
execute :sudo, 'service nginx restart'
within "#{release_path}" do
execute :sudo, './restart-gunicorn.sh'
end
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions restart-gunicorn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Auteur: Stéphane Oguey

# Trouver les ID des processus Gunicorn
PIDS=$(pgrep gunicorn)

# Si des processus Gunicorn sont en cours d'ex cution
if [ -n "$PIDS" ]; then
# Tuer les processus Gunicorn
kill -9 $PIDS
fi

sudo systemctl restart gunicorn

echo "Gunicorn restart done."

0 comments on commit cea7224

Please sign in to comment.