Open iilyak opened 5 years ago
I hear you but I think this might be outside the scope of alfred. I really like to see all the output so I tend to have another shell running when I'm rocking vim, or I have an integrated terminal running when I'm in vscode. I'm not a huge fan of running processes in the background(when there can be errors I need to see). Else, I'd use nohup or https://github.com/kcmerrill/kj. Regarding live reloading/compiling and bringing up containers this is actually my main purpose for building alfred. :)
I don't quite follow the multiple scripts to achieve this as you can do things with tasks and multitasks ... perhaps if you could clarify what you're looking for there might be a way to do what you're looking for.
One particular example. I use alfred to start my development environment. The goal is to start up all things I need and drop me into the container which has all dependencies and tools I need. I also prefer to edit the code on my host. Which means that I need to use -v ${PWD}:/src
flag when running docker container. Unfortunately this is extremely slow in case of docker on mac. There are multiple ways to speed it up. I adopted the one which uses unison
tool. This is how it works in my case:
alfred start
alfred
would run docker-compose up
unison
container exposed on localhost port 5000ssh agent
containerunison blabla localhost:5000
command.alfred shell <service>
which uses docker-compose exec {{ index .Args 0 }} bash
(this task is interactive: true
).I could write bash scripts to start things up. However one of the goals for this environment is to minimize the amount of commands and arguments developer need to remember.
Eventually I want to write a bootstrap.sh and alfred
config which would do the following.
bootstrap.sh
download and install golang and build alfred
it would also install unison
alfred
config would have
alfred
config inside the container would have project specific commands:
Makes sense.
Not sure if this will help but I typically do something like this(on my mac, as I use iterm, although this can be used with any terminal manager you're using).
Multitask the watch and then also run something like this https://apple.stackexchange.com/questions/110778/open-new-tab-in-iterm-and-execute-command-there
which will pop me into a new terminal(inside the container) while the original window has your watch.
Rationale
There are cases when some task need to be run forever in a loop. For example watching for changes in files, compiling and triggering live reload. Currently it can be implemented as
alfred watch &
:If there are multiple commands like this. In order to start all processes the one would have to create a separate script to call a number of alfred tasks. Also there is a problem of how to stop all tasks running in background. They are tottally independent processes so new invocation of alfred has no idea about them.
Proposal
Implement
alfred -d <name> <task>
command. This command would daemonize alfred task and remember somewhere (persistent storage maybe https://github.com/kcmerrill/alfred/issues/43) the mapping between name and pid. In addition we would implementalfred -k <name>
to stop the background task. The naming of commands is not important:-d/-k
--up/--down
--start/--stop