Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide alternative start / stop commands #37

Open
alexanderadam opened this issue Oct 24, 2016 · 3 comments
Open

provide alternative start / stop commands #37

alexanderadam opened this issue Oct 24, 2016 · 3 comments

Comments

@alexanderadam
Copy link

alexanderadam commented Oct 24, 2016

If there would be a config file with ip, start and stop commands (plus the already provided port) it would be possible to support other projects as well.

Like docker containers, VMs etc.

I would love to see this feature although I understand that it might add more complexity as well.

A myapp.yml would be nice like:

start_commands:
  - 'cd ~/myapp'
  - 'docker-compose up'
stop_commands:
  - 'docker-compose stop'
ip: '123.45.67'
port: 3002
@ysbaddaden
Copy link
Owner

I'm unsure, this is starting to be complicated, when it's supposed to be a zero configuration tool. Yet, it could be nice to have containers started/killed automatically. Maybe we can detect Docker (with or without Compose), and start/kill the containers as necessary? in addition to the rackup, shell and port forwarding strategies.

Or test and improve the shell script strategy to accept a start and stop argument. It already receives the PORT environment variable.

I'm using Vagrant with either VirtualBox or LXC (depending on the guest OS) myself, and usually use the port forwarding feature only. The port forwarding could be improved to target an optional IP too, so we could avoid a port redirection.

@alexanderadam
Copy link
Author

Well, the zero configuration variant for regular rackup applications should be still simple.
The manual config is just for people who just have cases were the zero configuration isn't enough anymore.

If you try to detect docker containers, vm's etc things will be much more complicated and error prone.
It would just be easier for the user if he gets the possibility to let prax "type" the commands he would type otherwise manually.

So you are currently starting and stopping the vagrant machines manually then or do you have "real" integration with prax?

@ysbaddaden
Copy link
Owner

It's not integrated. I'm manually starting the Vagrant boxes, because I work in the Vagrant boxes anyway. This is where everything is installed, and where I run tests and a webserver.

Actually, the following should already work, as long as you have a ${PORT}:3002 redirection in your Docker configuration. The current working directly should also already be your application's too. If it doesn't work, it's possible the shell script strategy doesn't work.

#! /usr/bin/env sh

docker-compose up

trap "docker-compose down" TERM

while true; do
  sleep 20 &
  wait $!
done

The sleep/wait combo is meant to keep the shell script alive, so it can receive the TERM signal. The while is to avoid sleep to continue running for too long after the shell script exits. This is too complicated to my taste, so maybe we could have a shell helper, so the script could be:

prax_start() {
  docker-compose up
}

prax_stop() {
  docker-compose down
}

Or for my own purposes:

PID=/tmp/prax_rackup.pid

prax_start() {
  vagrant up web
  vagrant ssh web -c "cd /vagrant && rackup -b 0.0.0.0 -P $PID"
}

prax_stop() {
  vagrant ssh web -c "[ -f $PID ] && kill `cat $PID`"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants