3

「script/mailman_server」に配置されたmailman_serverusingという名前のスクリプトを作成しましたgem "mailman"

    #!/usr/bin/env ruby
    require "rubygems"
    require "bundler/setup"
    require "mailman"

    #Mailman.config.logger = Logger.new("log/mailman.log")
    Mailman.config.poll_interval = 3
    Mailman.config.pop3 = {
      server: 'server', port: 110,
      username: "loginid",
      password: "password"
    }

    Mailman::Application.run do
      default do
        p "Found a new message"
        # 'perform some action here'
        end
    end

アカウントからすべてのメールを取得し、それらを処理します。

私は自分のdeploy.rbファイルを次のように持っています

set :stages, %w(production)     #various environments
load "deploy/assets"                    #precompile all the css, js and images... before deployment..
require "bundler/capistrano"            # install all the new missing plugins...
require 'delayed/recipes'               # load this for delayed job..
require 'capistrano/ext/multistage'     # deploy on all the servers..
require "rvm/capistrano"                # if you are using rvm on your server..
require './config/boot'           
require 'airbrake/capistrano'           # using airbrake in your application for crash notifications..

set :delayed_job_args, "-n 2"            # number of delayed job workers 


before "deploy:assets:symlink", "deploy:copy_database_file"
before "deploy:update_code",  "delayed_job:stop"  # stop the previous deployed job workers...
after "deploy:start",   "delayed_job:start" #start the delayed job 
after "deploy:restart", "delayed_job:restart" # restart it..
after "deploy:update", "deploy:cleanup" #clean up temp files etc.
set :rvm_ruby_string, '1.9.3'             # ruby version you are using...
set :rvm_type, :user

server "my_server_ip", :app, :web, :db, :primary => true 

set(:application) { "my_application_name" }
set (:deploy_to) { "/home/user/#{application}/#{stage}" }
set :user, 'user'
set :keep_releases, 3
set :repository, "git@bitbucket.org:my_random_git_repo_url"
set :use_sudo, false
set :scm, :git
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_via, :remote_cache
set :git_shallow_clone, 1
set :git_enable_submodules, 1

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
  task :copy_database_file do
    run "ln -sf #{shared_path}/database.yml #{release_path}/config/database.yml"
  end
end

サーバーにデプロイするたびにこのスクリプトを実行したいと考えています。また、コードをデプロイするときはいつでもこのスクリプトを停止する必要があります。

サーバーでカピストラーノを使用してこのスクリプトを開始または停止する方法がわかりません。

4

1 に答える 1