Sometimes MySQL crash for various reasons (out of memory), there is a simple hack to make sure MySQL running.
Save this to dbcheck.sh
if [[ ! `$PIDOF -s mysqld` ]]; then
$SERVICE mysqld restart # can be mysql or mariadb
echo "DB restarted"
echo "DB is healthy"
Make it executable by chmod +x dbcheck.sh , and setup a cronjob as root for it to run periodically (e.g. every minute)
* * * * * /home/jason/dbcheck.sh > /dev/null
Note that this is not considered a good practice, you should find out what is crashing the DB/service, but it is a simple hack to save your some time.
This article intend to give some pointers to developers new to Slack on how to integrate their services / workflow with it. You can add a message to Slack and get notified as simple as a command like this:
slack "Something is done"
My Use case
So my main purpose of using Slack it to get notified with certain events happen and implement it with minimum effort. For example, Continue reading “Use Slack as notification service in your workflow”
1. Logs and monitoring
You can view logs of a container by
docker logs [container_name]
And you can monitor output from a container by
docker logs -f [container_name]
2. Open a shell in the container
If you want to quickly dive into the container, Continue reading “5 Docker tricks make your life easier – Part 1”
Sometimes you want to know if a certain App/code/IDE changed something on the disk, this little script / command may come in handy.
install fswatch as a global command
Only fswatch is not enough, here is the script that does the trick
fswatch -0 $@ | while read -d "" event; \
Save as a script e.g. monitor.sh, then give it executable permission
Now run the script and supply the path as parameter, and you will start monitoring the directory
As Docker for Mac becomes available, it’s about time to ditch Docker Toolbox which requires a VM running in background. The migration is surprisingly easy. The Official doc recommend you to read this article “Docker for Mac vs. Docker Toolbox“, while I think it’s a pretty good read, I will simply tell you the steps to migrate if you just need the info. Continue reading “Migrating to “Docker for Mac” from Toolbox”
If you use docker for some time, there will be a lot of trash images, volumes that is not used by any containers. Here’s how to remove them. (warning: not reversible)
Remove dangling images
docker rmi $(docker images -qf dangling=true)
Remove dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
As seen from above commands, you may guess the nested command within the $(…) is used to list dangling images/volumes
List dangling images
docker images -f dangling=true
List dangling volumes
docker volume ls -f dangling=true
Ever want to use .env file config directly in Makefile? I found it not as easy as it sounds. I found this shell command on the web Continue reading “Using Dotenv config in Makefile (or anything)”
Docker containers are just like a computer, the networking between host and containers is affected by the firewall. My iptables has a default DROP all policy, but it will make the Containers cannot communicate with the host. Here is the fix you’ll need. Continue reading “Make Docker work with iptables”
Named volume is a new feature since Docker 1.9, it allows you to manage persistent data more easily, and also the volume can be provided by other storage drivers such as Glusterfs instead of “just a directory on the host”. This new feature is particularly useful in production environment. (On the Dev side, I think we still need mounted volume) Continue reading “Docker named volume explained”
It seems hard to find a complete step-by-step tutorial to install Jetty as a service (especially on CentOS), some of the tutorial online is somewhat outdated or does not work, so I will share what I’ve learnt. (painfully) Perhaps this tutorial will also be outdated at some point in the future, so I will state the current version of the software I use clearly. Continue reading “Install Jetty as a service on CentOS”