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

Tutorial or introduction? #199

Open
mohnstrudel opened this issue Oct 2, 2017 · 1 comment
Open

Tutorial or introduction? #199

mohnstrudel opened this issue Oct 2, 2017 · 1 comment

Comments

@mohnstrudel
Copy link

mohnstrudel commented Oct 2, 2017

I'd really love to use your gem, however I'm struggling with the basics. Would it be possible to create some sort of starter guide on how to use it?

Do I install the gem as standalone gem on the production server?
Do I include it in my application in the Gemfile?
Do the configs live in a separate folder on the production server or in a folder relative to my app?
Here what are variable values for the word 'project/s'? You use 'project1' and 'projects'. Do I need a separate folder for an eye-project? (/home/deploy/projects/eye)
What is the folder #{current_path}/deployment/? Is it supposed to be in my app? There is no such folder...

I'm using Puma on my production machine, when trying to install the gem as standalone gem on the server, copying the puma.eye from examples, I get following error:
deploy@71437:~$ eye load ~/eye/puma.eye working_dir '/home/deploy/eye/processes' is invalid

I'm completely clueless how to use it, links in the wiki are either non-existant or lead to Chinese/Japanese sites. Googling doesn't help either because the name 'eye' is rather pretty general.

@universal
Copy link

@mohnstrudel -- Here is how I use it:

I've a seperate eye-process per application, since I usually deploy apps to different users. I only use it with rails apps. I have a deploy directory in my RAILS_ROOT folder, where i put deploy specific configuration. Inside that folder I've the eye configuration, and other stuff like the config for whenever.

Whenever config to generate a @reboot cron task, to restart app after reboot.

every :reboot do
  current_path = "~/deploy/some_app"
  command "cd #{current_path} && bundle exec eye load deploy/config/production.eye"
end

Eye config to start puma and delayed job

BUNDLE = 'bundle'
RAILS_ENV = 'production'
ROOT = File.expand_path(File.join(File.dirname(__FILE__), %w[../ ../]))

Eye.config do
  logger "#{ROOT}/log/eye.log"
end

Eye.application :tierwohl do
  env 'RAILS_ENV' => RAILS_ENV
  working_dir ROOT
  trigger :flapping, times: 10, within: 1.minute

  process 'web-1' do
    daemonize true
    pid_file 'tmp/puma.pid'
    stdall 'log/web-1.log'

    start_command "#{BUNDLE} exec puma -C config/puma.rb"
    stop_signals [:TERM, 5.seconds, :KILL]
    restart_command 'kill -USR2 {PID}'

    # just sleep this until process get up status
    # (maybe enough to puma soft restart)
    restart_grace 10.seconds

    check :cpu, every: 30, below: 80, times: 3
    check :memory, every: 30, below: 200.megabytes, times: [3, 5]
  end

  (1..1).each do |i|
    process "delayed-job-#{i}" do
      stdall = "log/delayed-job-#{i}.log"
      start_command "bin/delayed_job start -i #{i}"
      stop_command "bin/delayed_job stop -i #{i}"
      pid_file "tmp/pids/delayed_job.#{i}.pid"
      start_grace 30.seconds
      stop_grace 45.seconds
    end
  end
end

I'm certain this config could be improved, but it works good enough for me so far. :-) I hope this helps you :-)

maybe someone can convert it to a wiki page or alike :-)

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

2 participants