我一直在使用 foreman 以集中方式扩展我的各种 ruby 进程,它对我来说非常有效。
无论如何,我想要一些功能来重新启动一个进程,甚至给它更多的控制,比如杀死一个进程并重新启动它,在当前的实现中,当我杀死一个进程时,整个进程在主工头 stop 。这里有任何解决方法或解决方案吗?
提前致谢
我有一个简单的Procfile,内容如下:
web: bundle exec rails server thin -p $PORT
worker: bundle exec rake jobs:work
Run Code Online (Sandbox Code Playgroud)
在Heroku上,这将启动N个工作任务,其中N是我将其缩放的任何东西.
在我的开发系统上,
$ foreman start
Run Code Online (Sandbox Code Playgroud)
只会启动一个工作任务.如果我想启动三个worker,我需要一个看起来像这样的Procfile:
web: bundle exec rails server thin -p $PORT
worker: bundle exec rake jobs:work
worker: bundle exec rake jobs:work
worker: bundle exec rake jobs:work
Run Code Online (Sandbox Code Playgroud)
这是一个有点迂腐的问题,但如果我希望我的开发环境像我的Heroku环境一样,那么启动N个工作任务的最佳方法是什么?是批准的方法来创建(例如)Procfile_local并通过它使用它foreman -f Procfile_local?
在Rails 4 + thin,quiet_assets gem工作得很好.
一旦我加入独角兽并与领班一起运行,资产再次变得嘈杂.
这有什么解决方案吗?
出于生产目的,我需要运行三个进程.这是我的procfile,我使用Foreman启动它们:
web: bundle exec rails s Puma -p $PORT
queuing: bundle exec clockwork clock.rb
workers: bundle exec rake resque:workers
Run Code Online (Sandbox Code Playgroud)
部署我正在使用Mina.在部署任务结束时启动Foreman的适当方法是什么?目前我开始是这样的:
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
to :launch do
queue "touch #{deploy_to}/tmp/restart.txt"
queue "bundle exec foreman start"
end
end
end
Run Code Online (Sandbox Code Playgroud)
...但我不认为这是正确的方式,因为"mina deploy"命令永远不会成功退出,本地控制台只是开始输出这些进程正在做的任何事情.
问题二:如何在单独的文件中分别初始化这三个进程中的每个进程的日志记录?
当其中一个进程崩溃时,如何防止杀死所有这三个进程?如何在崩溃时重新启动进程?
谢谢!
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) 我已经向heroku部署了一些django项目,并且无法弄清楚这里发生了什么或者从哪里开始调试.它似乎立即崩溃.
foreman start
Run Code Online (Sandbox Code Playgroud)
给我:
00:13:21 web.1 | started with pid 1242
00:13:22 web.1 | exited with code 3
00:13:22 system | sending SIGTERM to all processes
SIGTERM received
Run Code Online (Sandbox Code Playgroud)
Procfile:
web: gunicorn lvngd.wsgi:application
当我推送到heroku时它会立即崩溃.
我甚至不知道从哪里开始...我试图启动一个不同的应用程序,完全通过django教程尝试回溯,但我得到了相同的错误,所以它似乎是我的设置中的东西?
我之前部署的应用程序之间的唯一区别是它们是Django 1.5,我目前正在尝试推送Django 1.6.
我已经尝试重新安装heroku工具带,重新安装工头,重新安装gunicorn(gunicorn似乎与python manage.py run_gunicorn一起使用)和检查设置等.
当我尝试运行时,gunicorn lvngd.wsgi:application我得到一个跟踪错误然后gunicorn.errors.HaltServer: 但我不知道如何解决这个问题.
我正在关注https://devcenter.heroku.com/articles/getting-started-with-java上的"Heroku上的Java入门"指南 我按照这些步骤进行操作,直到我部署并成功执行从GitHub下载的应用程序.当我尝试使用该命令在Windows XP上本地执行它时
foreman start web
Run Code Online (Sandbox Code Playgroud)
我收到错误:
web.1 | started with pid 3388
web.1 | Error: Could not find or load main class Main
web.1 | exited with code 1
system | sending SIGKILL to all processes
Run Code Online (Sandbox Code Playgroud)
我的Procfile是:
web: java %JAVA_OPTS% -cp target\classes:target\dependency\* Main
Run Code Online (Sandbox Code Playgroud)
和
>echo %JAVA_OPTS%
-Xms256m -Xmx512m
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我如何解决?
我在Mac OSX上使用自制软件包管理器,我已经安装了heroku-toolbelt软件包,它应该包括git,heroku CLI和foreman.它似乎只包括前两个:
$ brew info heroku-toolbelt
heroku-toolbelt: stable 3.20.0
https://toolbelt.heroku.com/other
/usr/local/Cellar/heroku-toolbelt/3.20.0 (438 files, 3.5M) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/heroku-toolbelt.rb
$ which heroku
/usr/local/bin/heroku
$ which foreman
$ heroku --version
heroku-toolbelt/3.21.4 (x86_64-darwin13.0) ruby/2.1.2
$ foreman
bash: foreman: command not found
Run Code Online (Sandbox Code Playgroud)
任何想法为什么它没有出现?提前谢谢了.
目前,我正在通过输入foreman start命令行来运行我的解决方案,并且运行良好。我正在尝试使用 Visual Studio 代码调试我的代码。为此,我创建了一个 launch.json 文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/package.json",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "start",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个 tasks.json 文件来尝试从那一点启动程序:
{
"version": "0.1.0",
"command": …Run Code Online (Sandbox Code Playgroud) 我想我的运行rails server和slackbot在两个进程使用Procfile和gem 'foreman'。
但是当我使用foreman start机器人时,它只运行服务器并没有启动。我尝试删除 line bot 并尝试仅运行 web,但在这种情况下,我的服务器也没有启动它只显示started with pid 1502. 但是当我从另一个终端启动它时,rails s它启动没有问题。我用谷歌搜索了很多,似乎无法找到解决方案。非常感谢帮助。谢谢。
这是我的 Procfile :
web: bundle exec rails server -p $PORT
bot: rails runner -e development slackbot/slack.rb
Run Code Online (Sandbox Code Playgroud)