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

dokku ps #298

Closed
wants to merge 60 commits into from
Closed

dokku ps #298

wants to merge 60 commits into from

Conversation

slaskis
Copy link

@slaskis slaskis commented Nov 7, 2013

dokku-ps

A process management plugin for dokku.

Modeled after the process/dyno management of heroku.

Written to solve these problems:

  1. Restarting crashed containers.

    Because sometimes the process exits because of something like a memory leak and, until we have it fixed, we just want it to keep going.

    And the idea is to use upstart to handle the containers, as described in dockers host integration docs.

  2. Being able to start up non web processes.

Bonus problems to solve:

  1. Monitor & notify.

    I'm guessing since upstart is monitoring the respawning of containers it should be able to notify me by email, irc or something even cooler using some custom events.

  2. Process scaling.

    If we are able to add each process as a backend to the nginx config we should easily be able to load balance the requests over multiple processes. This PR seems like it would help a lot as we would only have to generate $APP_ROOT/nginx.conf with the processes defined in $APP_ROOT/PS. Something like:

    CONF="$APP_ROOT/nginx.conf"
    echo "upstream $APP {" > $CONF
    grep "^web=" $APP_ROOT/PS | while read line; do
      NUM=${line#*=}
      for ((i=1; i<=$NUM; i++)); do
        PORT=$(docker port $APP.web.$i 5000 | sed 's/0.0.0.0://')
        echo "server 127.0.0.1:$PORT;" >> $CONF
      done
    done
    echo "}" >> $CONF

Status

  • Install plugin
  • Deploy app
  • Restart a process dokku ps:restart APP web
  • Restart app dokku ps:restart APP
  • Scale processes dokku ps:scale APP web=4 worker=1
  • Stop a process (such as "web") dokku ps:stop APP web
  • Load balancing (of "web" processes only?)
  • Logs (is it possible to cat multiple streams into one?)
  • Cleanup and format the output/noise
  • Tests

Thoughts?

echo "-----> Starting $NAME"
ps_each start $APP $NAME $NUM
echo " $NUM processes up and running"
sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add a mandatory 5 seconds to all deploys?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, that was left there from when I thought docker needed some time to give me a port.

@progrium
Copy link
Contributor

progrium commented Nov 7, 2013

This is great! It may take some time to review. Maybe we can even simplify it a bit.

oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
docker kill $oldid > /dev/null
fi
dokku ps:deploy $APP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should figure out a way to make it so dokku doesn't depend on a plugin.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's a bit of a specific hack but would it suffice to wrap the current code in an if?

if [[ ! -f "$APP_PATH/PS" ]]; then 
  # current kill / start code here
fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't think I'd +1 this without a real solution to this.

On Thu, Nov 7, 2013 at 12:37 PM, Robert Sköld notifications@github.comwrote:

In dokku:

@@ -47,18 +47,17 @@ case "$1" in
APP="$2"; IMAGE="$3"
pluginhook pre-deploy $APP $IMAGE

  • kill the app when running

  • if [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
  •  oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
    
  •  docker kill $oldid > /dev/null
    
  • fi
  • dokku ps:deploy $APP

I know it's a bit of a specific hack but would it suffice to wrap the
current code in an if?

if [[ ! -f "$APP_PATH/PS" ]]; then

current kill / start code here

fi


Reply to this email directly or view it on GitHubhttps://github.com//pull/298/files#r7509242
.

Jeff Lindsay
http://progrium.com

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of this other PR: #296, maybe it could provide a bit more flexible solution?

But, if I understood the current implementation of pluginhook correctly, it would still do multiple deploys which seems a bit wasteful but maybe a flag to pluginhook which makes it only execute the last hook? Or is there a case when multiple deploy scripts would be desirable?

@shalakhin
Copy link

It would be awesome to have this in dokku. Thank you @slaskis for the contribution!

@AlJohri
Copy link
Contributor

AlJohri commented Mar 9, 2014

@slaskis Does your syslog plugin https://github.com/slaskis/dokku/tree/wip/logger-0.2/plugins/syslog already account for Logs (is it possible to cat multiple streams into one?).

Thanks for making this! It would be awesome to have this in dokku.

@slaskis
Copy link
Author

slaskis commented Mar 9, 2014

@AlJohri haha, yeah it's a pleasant side effect of using syslog. Log rotation is another one. And the possibility to send logs to a central place (like papertrail) is yet another one...

@AlJohri
Copy link
Contributor

AlJohri commented Mar 21, 2014

That's awesome! @slaskis

What's left to be done then in terms of merging this much awaited PR? :)

@slaskis
Copy link
Author

slaskis commented Mar 22, 2014

@AlJohri I wrote about some issues I have still in this comment: #386 (comment).

(copied it to here, since it's relevant to this issue)

Zero downtime is an issue with ps that I didn't get around to solve.

Mainly because the way I used named docker containers, which was really nice and convenient, but it wouldn't allow it to have two containers with the same name (and renaming them was not possible). So to get it to work I'm thinking that it would have to move from named docker containers and store the container id in a file in something like $APP/ps/$name which simply reads the container name.

But I have been running ps in production for a few months now and I have found some other kinks that needs to be fixed as well. And I'm curious to try it with newer docker too, might solve a few instabilities.

@slaskis
Copy link
Author

slaskis commented Mar 22, 2014

But the main issue with getting this merged is that I haven't spent any time on it since like december. I've been busy with unrelated projects which take up all my time.

@josegonzalez
Copy link
Member

@slaskis any chance you could write a note on what other "kinks" you found with this plugin? I can get it merged if I know what issues you've found :)

@slaskis
Copy link
Author

slaskis commented Nov 21, 2014

@josegonzalez unfortunately I can't remember what they were anymore :(

@josegonzalez
Copy link
Member

Are you still using dokku in prod? Any chance you have any other changes?

@slaskis
Copy link
Author

slaskis commented Nov 26, 2014

@josegonzalez actually they are still alive and kicking but I haven't touched them for almost exactly a year (the campaign for which the servers were created for was just until christmas).

There are some changes implemented for a syslog plugin in a logger branch which is being used in those too. But that's based on whatever docker version that was released a year ago (definitely pre-1.0). So I'm sure the logging and other stuff could be handled better now.

@josegonzalez
Copy link
Member

I think we're not going to implement this as is, and instead provide a pluginhook. For instance, I can foresee a plugin that scales AWS instances with dokku containers, or one that modifies the number of procs running inside of a supervisor controlled container.

If anyone has any comments on that, feel free to pile them on, but doing anything more inside of dokku feels a bit weird (because there are so many corner cases).

@josegonzalez
Copy link
Member

We have an official ps plugin as of #897, and the items not implemented here are I think out of scope. Feel free to open a new PR to implement some of these in the new plugin as you see fit.

This was referenced Apr 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants