running multiple commands in multiple terminal tabs

67 views
Skip to first unread message

William Hertling

unread,
Sep 15, 2015, 5:49:43 PM9/15/15
to pdxruby
I'm trying to resurrect an old project, which is a cluster of ruby scripts and rails projects from about two years ago. The project is composed of 3 different rails servers, two different sets of resque workers, a redis database, and a couple of schedulers. In those dark ages, we had a ruby script that would use the rb-appscript gem to interface with Apple Terminal and run all of the dependencies in different terminal tabs.

As we try to bring this project back to life, the main that seems to have broken is in the way the ancient rb-appscript gem tries to interact with current OSX. rb-appscript hasn't been updated in years and years.

Is there any replacement for rb-appscript? Is there any better, newer way of doing this?




Paul Jungwirth

unread,
Sep 15, 2015, 5:59:11 PM9/15/15
to pdx...@googlegroups.com
Hi William,

This sounds like it might be a nice use-case for Docker. Or if you want
something that can automatically manage tabs, maybe tmux? I have bash
functions like this for all my projects:

function foo-code {

env_name=code
long_name=foobarbaz
short_name=foo
tmux_session=${short_name}-${env_name}

if tmux list-sessions | grep ${tmux_session}; then
tmux attach-session -t ${tmux_session}

else
cd ~/src/${long_name}/site/app/models && \
tmux new-session -d -s ${tmux_session} && \
tmux rename-window -t ${tmux_session}:1 models

cd ~/src/${long_name}/site/app/controllers && \
tmux new-window -t ${tmux_session}:2 -n controllers

cd ~/src/${long_name}/site/app/views && \
tmux new-window -t ${tmux_session}:3 -n views

cd ~/src/${long_name}/site/app/assets/stylesheets && \
tmux new-window -t ${tmux_session}:4 -n css

cd ~/src/${long_name}/site/app/assets/javascripts && \
tmux new-window -t ${tmux_session}:5 -n js

tmux select-window -t ${tmux_session}:1 && \
tmux -2 attach-session -t ${tmux_session}
fi
}

In your case you can skip the cd'ing, and you can pass extra arguments
to those new-window commands to run shell commands in each one.

Paul
> --
> You received this message because you are subscribed to the Google
> Groups "pdxruby" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pdxruby+u...@googlegroups.com
> <mailto:pdxruby+u...@googlegroups.com>.
> To post to this group, send email to pdx...@googlegroups.com
> <mailto:pdx...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pdxruby/d0e1c7eb-8768-431f-81a7-f721ad0c0da0%40googlegroups.com
> <https://groups.google.com/d/msgid/pdxruby/d0e1c7eb-8768-431f-81a7-f721ad0c0da0%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Jason LaPier

unread,
Sep 15, 2015, 6:13:30 PM9/15/15
to Paul Jungwirth, pdx...@googlegroups.com
Foreman is a quick and easy way to run multiple ruby scripts/services simultaneously, though they'll all be in the same terminal session. 


To unsubscribe from this group and stop receiving emails from it, send an email to pdxruby+u...@googlegroups.com.
To post to this group, send email to pdx...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdxruby/55F89458.5050109%40gmail.com.

Mac Martine

unread,
Sep 15, 2015, 6:39:17 PM9/15/15
to pdxruby
Along the lines of Paul's suggestion, I came across this this morning, which I haven't yet tried, but I'll be a very happy camper if it works well: https://github.com/tmux-plugins/tmux-resurrect

-Mac

Maher Hawash

unread,
Sep 15, 2015, 7:22:12 PM9/15/15
to Mac Martine, pdxruby
I use https://github.com/tony/tmuxp to open multiple panes with each executing a different script.

Maher

To unsubscribe from this group and stop receiving emails from it, send an email to pdxruby+u...@googlegroups.com.
To post to this group, send email to pdx...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdxruby/ffa00562-0f8f-4a95-9d7c-1a5f0adcd0da%40googlegroups.com.

Jesse Cooke

unread,
Sep 16, 2015, 12:41:23 AM9/16/15
to Maher Hawash, Mac Martine, pdxruby

I really like https://github.com/tmuxinator/tmuxinator for my projects with a lot of service dependencies.


Scott Tamosunas

unread,
Sep 16, 2015, 12:11:21 PM9/16/15
to pdxruby
As Jason mentioned, I'd check out Foreman. It's quick and easy to setup. 

- Scott 

Jesse Cooke

unread,
Sep 17, 2015, 1:14:00 AM9/17/15
to Scott Tamosunas, pdxruby

One reason I opted for tmuxinator over Fireman is that (at least in the past) if you wanted to restart one service with Foreman you had to restart all of them. Maybe there's a way to do that now with more fidelity.


--
You received this message because you are subscribed to the Google Groups "pdxruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdxruby+u...@googlegroups.com.
To post to this group, send email to pdx...@googlegroups.com.

Scott Tamosunas

unread,
Sep 17, 2015, 11:54:13 AM9/17/15
to Jesse Cooke, pdxruby
I don't see a way to restart one service with Foreman. Typically if I find that I need to continually restart a service in my development, I'll comment that service out of my Procfile and run that service in a separate terminal window where I can restart as needed while running the remaining with foreman. 

William Hertling

unread,
Sep 17, 2015, 8:10:05 PM9/17/15
to pdxruby
Thanks all the for the recommendations! I'm going to give tmuxinator a try.
Reply all
Reply to author
Forward
0 new messages