工头没有在 rails 上处理佣金任务
Foreman not working with a rake tast on rails
所以我的 rails 后端 运行 连接在端口 3001 上,React 前端 运行 连接在端口 3000 上。
我想设置一个简单的 rake start
任务来启动两者。
为此,我使用了 foreman
gem,当我 运行: foreman start -f Procfile.dev
时效果很好。
但是:当我 运行 我的任务:rake start
时,我收到以下错误:
Running via Spring preloader in process 36257
15:56:57 web.1 | started with pid 36258
15:56:57 api.1 | started with pid 36259
15:56:57 api.1 | /usr/local/opt/rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/foreman-0.64.0/bin/foreman-runner: line 41: exec: PORT=3001: not found
15:56:57 api.1 | exited with code 127
15:56:57 system | sending SIGTERM to all processes
15:56:57 web.1 | terminated by SIGTERM
这是我的 start.rake
文件:
namespace :start do
desc 'Start dev server'
task :development do
exec 'foreman start -f Procfile.dev'
end
desc 'Start production server'
task :production do
exec 'NPM_CONFIG_PRODUCTION=true npm run postinstall && foreman start'
end
end
task :start => 'start:development'
和我的 Procfile.dev
文件:
web: cd client && PORT=3000 npm start
api: PORT=3001 && bundle exec rails s
有什么想法吗?
我不认识 Foreman,但每天早上我都会用 teamocil. Here is an example 文件启动我的开发环境。
为您的 .bash_alias 文件添加别名:
alias s2="cd /home/manuel/chipotle/schnell && tmux new-session -d 'teamocil schnell' \; attach"
所以您只需要在控制台中输入 "s2",包括数据库提示在内的所有内容都准备就绪。
我遇到了同样的问题。我不确定为什么,但是当 foreman 来自 rake 运行 时,它无法在同一行处理多个命令,例如
web: cd client && PORT=3000 npm start
为了解决这个问题,我将 Procfile.dev 更改为
web: npm start --prefix client
api: bundle exec rails s -p 3001
在我的 package.json 中,我更改了
"scripts": {
"start": "react-scripts start",
...
}
到
"scripts": {
"start": "PORT=3000 react-scripts start",
...
}
这允许您为反应和 rails 服务器指定端口,并且可以很好地与
foreman start -f Procfile.dev
和 rake start
我知道我有点晚了,但基本上你不应该使用多行命令,总是尽量避免那样。你可以改变你的语法并使用一些标志使其在线:
web: npm start --port 3000 --prefix client
api: bundle exec rails s -p 3001
希望对遇到同样问题的人有所帮助。
快乐编码
所以我的 rails 后端 运行 连接在端口 3001 上,React 前端 运行 连接在端口 3000 上。
我想设置一个简单的 rake start
任务来启动两者。
为此,我使用了 foreman
gem,当我 运行: foreman start -f Procfile.dev
时效果很好。
但是:当我 运行 我的任务:rake start
时,我收到以下错误:
Running via Spring preloader in process 36257
15:56:57 web.1 | started with pid 36258
15:56:57 api.1 | started with pid 36259
15:56:57 api.1 | /usr/local/opt/rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/foreman-0.64.0/bin/foreman-runner: line 41: exec: PORT=3001: not found
15:56:57 api.1 | exited with code 127
15:56:57 system | sending SIGTERM to all processes
15:56:57 web.1 | terminated by SIGTERM
这是我的 start.rake
文件:
namespace :start do
desc 'Start dev server'
task :development do
exec 'foreman start -f Procfile.dev'
end
desc 'Start production server'
task :production do
exec 'NPM_CONFIG_PRODUCTION=true npm run postinstall && foreman start'
end
end
task :start => 'start:development'
和我的 Procfile.dev
文件:
web: cd client && PORT=3000 npm start
api: PORT=3001 && bundle exec rails s
有什么想法吗?
我不认识 Foreman,但每天早上我都会用 teamocil. Here is an example 文件启动我的开发环境。
为您的 .bash_alias 文件添加别名:
alias s2="cd /home/manuel/chipotle/schnell && tmux new-session -d 'teamocil schnell' \; attach"
所以您只需要在控制台中输入 "s2",包括数据库提示在内的所有内容都准备就绪。
我遇到了同样的问题。我不确定为什么,但是当 foreman 来自 rake 运行 时,它无法在同一行处理多个命令,例如
web: cd client && PORT=3000 npm start
为了解决这个问题,我将 Procfile.dev 更改为
web: npm start --prefix client
api: bundle exec rails s -p 3001
在我的 package.json 中,我更改了
"scripts": {
"start": "react-scripts start",
...
}
到
"scripts": {
"start": "PORT=3000 react-scripts start",
...
}
这允许您为反应和 rails 服务器指定端口,并且可以很好地与
foreman start -f Procfile.dev
和 rake start
我知道我有点晚了,但基本上你不应该使用多行命令,总是尽量避免那样。你可以改变你的语法并使用一些标志使其在线:
web: npm start --port 3000 --prefix client
api: bundle exec rails s -p 3001
希望对遇到同样问题的人有所帮助。 快乐编码