Playing with docker-compose and Symfony
After playing with docker and jekyll, I had to look at docker-compose to implement a PHP project using the latest Symfony version.
Here is a list of “useful” bash commands that I always seem to forget …
top -bn 2 -d 0.1 | grep -E '^(%)?Cpu' | tail -n 1 | awk '{print $2+$4+$6}'
# top -b for batch
# top -n 2 for 2 sequences
# top -d 0.1 difference of 0.1 second
# grep -E for regex pattern - some OS will start the line with %Cpu and some other won't
# tail -n 1 to get the last line
# awk to add numbers up
free -t | grep 'Total' | awk '{print ($3 * 100) / $2 }'
# free -t to display the total
# grep the last line
# awk to make a percentage
docker ps -aq | wc -l
# docker ps will list the docker containers - you can filter stuff here with the --filter parameter
# wc -l counts the total of line
date +%s%N | cut -b1-13
# cut -b1-13 will keep the 13 first digits which is what we want because the date will return the nano seconds
Sometimes people fall asleep in front of their screen so a simple read -p "your question:" $value;
will be prompted for ever… Add a timeout!
printf "What is your favourite colour?\n"
read -t 10 $colour;
if [[ $? = "1" ]]; then
printf "Are you asleep?"
read -t 10 $colour;
fi
Note that once the timeout of 10 seconds is reached, the command will fail with the error code “1”.
After playing with docker and jekyll, I had to look at docker-compose to implement a PHP project using the latest Symfony version.
A quick tip about making your jekyll blog faster to load and render!
Almost 2 years since the last post so let’s be proactive and have a look at Docker with Jekyll!
Let’s say you want to run a script forever (like a job queuing system that needs to constantly listen to incoming jobs) you could just start the process with a php my-script.php
and be done with it (HAHA jk) but then how do you make sure it always run? And what if you want to monitor it?
We previously saw how to log your deployments with codebase, I am now going to show you how to log the exceptions from a symfony project (2.3+) in your codebase!
I use codebase at work for hosting our projects using git. I discovered recently that I could also log every deployment I make with capifony on either our staging or production environment (or both).
I have been working with Symfony2 for a while now and recently I have been looking at deploying symfony projects on remote servers (in my case, [AWS]) without having to SSH and manually run whatever commands the projects need to be run.
Logging into a remote server from your terminal could be a pain if you use the ssh command with the options of your private key, username and stuff. Fortunately, you can create a config file for your hostnames.
Here is my ~/.gitconfig
for aliases - which could probably be improved.
Go get the last version of Thunderbird for your architecture in your language.
Hello everybody (well, at least you reader)!