Unicorn不是由upstart脚本运行.
rvm 1.25.23 ruby 2.1.1 Rails 4.1
配置/ deploy.rb
desc 'Foreman init'
task :foreman_init do
on roles(:all) do
foreman_temp = "/home/deployer/tmp/foreman"
execute "mkdir -p #{foreman_temp}"
execute "ln -s #{release_path} #{current_path}"
within current_path do
execute "cd #{current_path}"
execute :bundle, "exec foreman export upstart #{foreman_temp} -a #{application} -u deployer -l /home/deployer/apps/#{application}/log -d #{current_path}"
end
sudo "mv #{foreman_temp}/* /etc/init/"
sudo "rm -r #{foreman_temp}"
end
end
Run Code Online (Sandbox Code Playgroud)
/etc/init/depl-web-1.conf
start on starting depl-web
stop on stopping depl-web
respawn
env PORT=5000
setuid deployer
chdir /home/deployer/apps/depl/current
exec bundle …Run Code Online (Sandbox Code Playgroud) 我正在尝试解析一个大型XML文件.我正在使用Saxerator.
我的哈希有一种树:
obj= {
"id"=>'1', "groups" =>{
"group" =>[
{"id"=>"2", "groups"=>{}},
{"id"=>"3", "groups"=>{}},
{"id"=>"4", "groups"=>{
"group"=>[
{"id"=>"5", "groups"=>{}},
{"id"=>"6", "groups"=>{}},
]}}
]}}
Run Code Online (Sandbox Code Playgroud)
我事先并不知道树的深度.我有一个问题.我不知道如何在数组中转换它.结果应该是这样的:
[{"id"=> "1", "parent_id"=> "0"},
{"id"=> "2", "parent_id"=> "1"},
{"id"=> "3", "parent_id"=> "1"},
{"id"=> "4", "parent_id"=> "1"},
{"id"=> "5", "parent_id"=> "4"},
{"id"=> "6", "parent_id"=> "4"}]
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?