Command Line Interface | Use the 4 CLIs to Manage Middleware
A command line interface is a User Interface | Human Computer Interface | Tool for managing Middleware Services
There are 4 types of Command Line Interface.
3 Ways to Interact with Middleware Services
We must interact, invoke, evoke and administer middleware services. The 3 ways to do this are via a GUI ( a Graphical User Interface ), a CLI ( Command Line Interface ) or an Intermediary Application.
- through user interfaces
- via the command line
- via intermediary applications
Why Use The Command Line?
The most productive interaction interface is the command line, and it is also the most ignored! Steal a march by interacting with middleware via a CLI (Command Line Interface).
Repeatedly Issuing Commands
The biggest advantage of the command line is the ability to script the commands you use. Also communication with colleagues is simplified. You don’t need to give them screen shots with arrows of where to click. You can just give them the command.
A mantra for service administrators is DRY – Don’t Repeat Yourself.
The 4 Command Line Interfaces
There are 4 distinct ways of administering ( managing ) middleware services through the command line. You need to know their pros and cons.
- the custom cli – mysql and play2 have a custom command line interface
- the custom command – mysqladmin, VBoxManage, svnadmin, svn checkout and javac are all custom commands
- the global command – sudo service apache2 restart, sudo service mysql restart, sudo service jenkins restart
- the custom script – a custom script like
do-mysql-backupcan execute a sequence of commands
1. The Custom CLI
To use a custom cli you go into the command line then log into the cli. MySQL for example gives you a custom cli. They are powerful but have a major drawback.
scripting – They are not designed for scripting. You can’t easily migrate your commands into a script.
2. Custom Commands
Custom commands are incredibly powerful for managing your middlewares services. You can
- VBoxManage createvm – create or clone a virtual machine
- svn checkout – checkout a repository under subversion control
- mysqldump … perform a mysql backup
These commands can be scripted in the future to perform big powerful blocks of work in an efficient manner.
3. Global Commands
Global commands are powerful because they apply to most (if not all) middleware services. They are available for the most common tasks so whenever possible, use them. Examples are
- sudo service restart <<service-name>>
- sudo apt-get install <<service-name>>
- ps -aux | grep <:<:service-name>>
4. Custom Scripts
You’ll waste your time if you jump in and start scripting everything.
Use the commands first and then script the command groups that you find yourself repeating.
Avoid large scripts – Large scripts are extremely painful – when you repeat them they will most likely fail. They are not designed to be robust. To manage middleware in a robust way it is worth investing time into learning frameworks like puppet and apt which are designed to solve the problem of repeatable management of middleware services.