Guest User

Untitled

a guest
Jun 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. namespace :specjour do
  2. def specjour_dir
  3. "~/.specjour/#{fetch(:project_name)}"
  4. end
  5.  
  6. def specjour_pid_file
  7. specjour_dir + "/manager.pid"
  8. end
  9.  
  10. task :start, :roles => :test do
  11. run "mkdir -p #{specjour_dir}"
  12. run "mkdir -p #{project_path}"
  13.  
  14. run "cd #{project_path} ; screen -dmS specjour specjour ; true"
  15.  
  16. screens = capture "screen -ls ; true"
  17. logger.info screens
  18.  
  19. match_data = screens.match /(\d+)\.specjour/
  20. pid = match_data[1]
  21.  
  22. run "echo #{pid} > #{specjour_pid_file}"
  23. end
  24.  
  25. task :stop, :roles => :test do
  26. run %Q{if [ -f #{specjour_pid_file} ] ; then kill $(cat #{specjour_pid_file}) ; rm #{specjour_pid_file} ; screen -wipe ; fi ; true}
  27. end
  28.  
  29. task :pid, :roles => :test do
  30. pid = capture "echo #{specjour_pid_file}"
  31. logger.info "PID: #{pid}"
  32. end
  33. end
Add Comment
Please, Sign In to add comment