工头不能在铁轨上使用耙子品尝

时间:2018-10-10 14:07:40

标签: ruby-on-rails reactjs foreman

因此,我的rails后端运行在端口3001上,并且可能使React前端运行在端口3000上。

我想设置一个简单的GuestUser任务来同时启动两者。

为此,我使用了rake start gem,它在运行时可以完美运行:foreman

但是:当我运行任务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

有什么想法吗?

3 个答案:

答案 0 :(得分:1)

我不认识Foreman,但是每天早晨,我都会从teamocil开始我的开发环境。这是一个example文件。

为您的.bash_alias文件添加别名:

 alias s2="cd /home/manuel/chipotle/schnell && tmux new-session -d 'teamocil schnell' \; attach"

因此,您只需要在控制台中键入“ s2”,所有内容(包括数据库提示符)便已准备就绪。

答案 1 :(得分:1)

我遇到了同样的问题。我不知道为什么,但是当工头从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",
    ...
}

这使您可以同时指定React和Rails服务器的端口,并且可以同时使用它们

foreman start -f Procfile.devrake start

答案 2 :(得分:0)

我知道我来晚了一点,但是从本质上讲,您不应该使用多行命令,请始终尝试避免这样做。您可以更改语法并使其在线,并带有一些休假标志:

web: npm start --port 3000 --prefix client 
api: bundle exec rails s -p 3001

我希望它可以帮助遇到相同问题的任何人。 快乐编码