Turn Off The Lights

After upgrading to macOS Sierra, and having Apex fail to work locally anymore, I decided it was time to build a dev instance, on EBS within EC2. I found a good idea from CloudSSH, but I really wanted to allow my instance to run docker commands while I was away. I decided to add the "--no-stop" flag to CloudSSH and just handle terminating the instances myself using a cronscript.


Here's the script:

#!/bin/sh
# Don't even bother checking if we haven't been up for more than
# 3500 seconds (just under 1 hour)
UPTIME=`cat /proc/uptime|awk '{printf "%i", $1}'`
if [ "$UPTIME" -gt "3500" ]
then
  if [ -z "$(who)" ]
  then
    if [ -z "$(docker ps -q)" ]
    then
      shutdown -P now
    fi
  fi

fi

And here's the /etc/cron.d/turn-off-the-lights file:

*/5 * * * * root /usr/local/bin/turn-off-the-lights


I also set up a nice little bash function to handle automatically configuring most of the common things I did for CloudSSH. I did this instead of an alias because I have multiple AWS profiles that I connect to:

# Connect to a "Cloud Environment"
typeset -A CLOUD_INSTANCE_ID
CLOUD_INSTANCE_ID+=(aci i-MY-DEV-INSTANCE)
CLOUD_INSTANCE_ID+=(newstex i-OTHER-DEV-INSTANCE)
cloud(){
  export AWS_REGION=us-east-1
  export AWS_PROFILE=$1
  $HOME/bin/cloudssh --no-stop ec2-user@${CLOUD_INSTANCE_ID[$1]}.us-east-1 -- -i ~/.ssh/$1-cmoyer.pem -o HostKeyAlias=${CLOUD_INSTANCE_ID[$1]}
}
cloud_profiles=(aci newstex)
compctl -k cloud_profiles cloud


Now I can just type "cloud aci" and automatically get logged into my ACI dev instance. Note that using "HostKeyAlias" allows me to not have to re-verify the host key every time the IP address changes.

Comments

casinononaams said…
There is also our famous QA team, checking on zipjob review every essay and paper written by our writers before sending the final draft over to a customer.
unknown said…
Before the writer, I was the best developer but recently I changed our field for some issues. When the last week also took law writing service from the best law essay writing services Manchester the reason is that I'm not a professional in the law writing.
hastenchemical said…
Taking inspiration from CloudSSH and customizing it with the "--no-stop" flag demonstrates resourcefulness in allowing for uninterrupted usage of Docker commands. Similarly, Refrigerated Courier Services – Texas provide customized and reliable transportation solutions for temperature-sensitive goods, adapting to specific needs and ensuring seamless delivery across different locations and timeframes.
Steven Paul said…
It's impressive that you were able to adjust to macOS Sierra's new features and find a workaround for your development instance on EBS within EC2. Instance termination is handled by a cron script, and the addition of the "--no-stop" argument to CloudSSH demonstrates your proactive nature. The Fast X Jason Statham Beige Jacket is a great addition to your wardrobe if you're looking to step up your fashion game.

Vava Store said…
It is very awesome to know about that. I appreciate your blog. however, the Vava store is where you can find your favorite character jackets the Spider man tuxedo is a stylish and unique take on traditional formal attire. shop now at the Vava store with the best quality jackets.
Not only will turning off the lights save you money on your utility bills, but it will also promote a sense of responsibility and mindfulness in your daily life. By actively participating in this simple act, you are setting an example for others to follow.

So, let's take my online class for me on turning off the lights. Together, we can make a difference by embracing this easy habit that will benefit us all in the long run. Remember, every small action counts towards creating a brighter future for generations to come.
Ramma Foundation Repair specializes in Edmonton foundation repair, offering trusted solutions for all your foundation needs. With expert knowledge and quality service, we ensure the stability and longevity of your property.
harperpaul said…
A night mode for reading, an eye protection mode, and possibilities to add unique backdrop images or effects to the darkened area are all included in some "Turn Off The Lights" versions.
divorcio de nueva jersey
Future Style said…
Italian luxury is personified in Benedetta bags, which feature superb craftsmanship and meticulous attention to detail. With its modern styles and high-quality materials, they elegantly and timeless elevate any ensemble. Benedetta bags are the height of sophistication and style.
Monster Rabbit said…
"Monster Rabbit" is a premium blend of natural ingredients, including royal performance honey, known for its enhancing properties. Experience heightened vitality and performance with this potent formula designed to boost energy and overall well-being.
CMOLDS proudly stands as the epitome of excellence in mobile app development, earning the title of the best mobile app development company in dubai. With a relentless pursuit of innovation and a commitment to exceeding client expectations, we deliver unparalleled mobile solutions tailored to your business needs. Trust CMOLDS to elevate your digital presence and propel your business forward in the vibrant tech hub of Dubai.