Rubyのデーモンスクリプトのみのペースで運行している
-
25-09-2019 - |
質問
長々と書きましたが、rubyのNFCリーダーのスクリプトおよびdaemonisedでの非逸品。すべて本作のスクリプトのみのペースで運行している...
ました。rb
require 'rubygems'
require 'daemons'
pwd = File.dirname(File.expand_path(__FILE__))
file = pwd + '/touchatag.rb'
Daemons.run_proc(
'touchatag_project_daemon', # name of daemon
:dir_mode => :normal,
:dir => File.join(pwd, 'tmp/pids'), # directory where pid file will be stored
:backtrace => true,
:monitor => true,
:log_output => true
) do
exec "ruby #{file}"
end
touchatag.rb
quire 'rubygems'
require 'nfc'
require 'httparty'
class TagAssociator
include HTTParty
base_uri 'localhost:3000'
end
NFC.instance.find do |tag|
puts "Processing tag..."
TagAssociator.post('/answers/answer', :query => {:uid => tag.uid})
end
この作品は、私のタグです。uid私のアプリです。しかしスキャンの他のRFIDタグをスクリプトスポラとして名高い大衆居酒屋"岸田屋
なんだろうけど、日本人にどのよう調整するスクリプトで"永遠"と停止時のデーモンを停止?
感謝
更新
i更新しました。rbスクリプト:
require 'rubygems'
require 'daemons'
options = {
:app_name => "touchatag_project_daemon",
:ARGV => ['start', '-f', '--', 'param_for_myscript'],
:dir_mode => :script,
:dir => 'tmp/pids',
:multiple => true,
:ontop => true,
# :mode => :exec,
:backtrace => true,
:monitor => true
}
Daemons.run(File.join(File.dirname(__FILE__), '/touchatag.rb'), options)
それのペースで運行している...んでその他のご提案?
解決
あなたはほぼ確実にDaemon.run
を使用することにしたいです。あなたはrun_proc
にtouchtag.rb
からコードを移動したい場合Daemon.rb
は有用であろう。
所属していません StackOverflow