3 comments

[ 2.9 ms ] story [ 14.5 ms ] thread
Made this thing, curious if it can actually be useful to anyone.

A problem is happening at work with contention for a particular resource (a pre-production demo environment).

The developers have to continually negotiate taking turns to occupy the environment (to get their changes previewed just before they are launched). There's only one of those preview environments because it uses the same db as the main production system.

So I guess I'm playing with the idea of automating that conversation away. Also, the webhooks are neat; lets the person who adds themselves to the queue decide exactly how (slack/pagerduty/etc) they want to be notified.

SEIZE THE CONCH.

It'd be better if the lock (Conch, sorry!) was acquired when you request the resource, and automatically released. In that vein, you'd need to write bespoke code for the "pre-production demo environment". Maybe there is something on the machine that lets only one SSH happen at a time. It could use your very cool Conch API to broadcast that to the Conch website so people can check before trying to SSH in. However that custom code is probably to be written by the users not yourself. But what might be helpful is a shell script "conchrun" that will run a command if the conch can be secured, and then releases the conch once the command exits.
That's sort of how it works. You request the conch, and if no-one else has it then it's yours.

Otherwise you're in the queue, waiting... always waiting, until finally the conch falls from your predecessor's grip - and you get notified via email or webhook.

Or as a last resort, by polling:

  while [ 1 ]; do
    if [ "$(curl -sfL conchable.com/bearer ...)" == "me" ]; then
      echo "THE CONCH IS MINE!"
      exit 0
    fi
    sleep 30
  done