One you can do is simply:
rails server & rake jobs:work
It'll run rails server
as background job, which you can get back to foreground with fg
. It can be annoying that you'll get output from both processes mixed.
I'm not sure what are your needs and what you expect but maybe it would be good for you to use screen
(or tmux
) to run them in parallel and be able to switch between.
You can do your own .screenrc
script which will run the server and any other commands when automatically for you.
There is a little problem that if you run the server from it and you close it (ctrl+c) than you'll loose it's screen window. Fortunately there is a solution for that as well (worked-out on the SO as well - you can read more about it here)
So, I use some helper script for that .run_screen
(don't forget to chmod +x
it):
#!/bin/bash
/bin/bash -i <<<"$*; exec </dev/tty"
Than I have .screenrc_rails
file:
#shell -${SHELL}
caption always "%n(%t) %= %{b}@%H[%l] : %{r}%c:%s"
termcapinfo xterm ti@:te@
termcap xterm 'AF=\E[3%dm:AB=\E[4%dm'
terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'
startup_message off
screen -t server 2 ${HOME}/.run_screen rails s
screen -t spork 3 ${HOME}/.run_screen bundle exec spork
screen -t dev_log 4 ${HOME}/.run_screen tail -f ./log/development.log
screen -t test_log 5 ${HOME}/.run_screen tail -f ./log/test.log
screen -t bash 0
screen -t bash 1
And an alias ( screenr(ails) ) defined at .bash_profile
:
alias screenr='screen -c ~/.screenrc_rails'
If you don't know screen
than start from ctrl+a
, "
. ctrl+a
, ?
will give you some help.
I hope you'll enjoy it.