Introduction
MageHost focuses on empowering customers to manage their own hosting account. Our customer's developers have SSH access, which is used for changes, deployment and automation. To provide an easy entry point for a growing number of management tasks of the hosting account we have created our own CLI tool: mhcli
This tool is based on Symfony console and has tabbed autocomplete.
Commands
Below is a description of our commands and how you can use them in real situations.
This list will gradually grow depending on the needs of our customers and automation.
When in doubt, you can always use --help
after any command.
mhcli account:info:show
This command gives more info on the whereabouts of credentials and paths needed to connect to the services in your account.
mhcli account:services:show
This lists all linked services in your account and their versions, this can come in handy when looking for bugs / checking change logs.
mhcli php:version:switch {PHPversion}
This will switch your PHP version. When your environment has custom settings or extensions that are not covered, you will be asked to contact our support so we can switch manually to retain them. To list what PHP versions are available, you can just run the command without a predefined version.
mhcli php:newrelic:add {licensekey}
Will add the newrelic daemon to the current PHP version and reload PHP for it to work. You will need the New Relic license key
mhcli php:newrelic:remove
Will remove the new relic daemon from the current PHP version
mhcli ssl:domains:add {domain} [domain]
This command checks your domain settings and if they pass, it adds your domain to the certificate.
Since we check a lot of points against the original name server (CAA, IPV4/IPV6, validation with a file,...), the command might have a small delay depending on how fast our queries get a response.
Warning: when swapping domains, please make sure you add the new domain to the certificate before removing the A/AAA record. Use mhcli ssl:domains:remove
after the add.
mhcli ssl:domains:remove {domain} [domain]
This command removes the requested domain. It will not perform extra checks against the original name server since you might have removed the domain before removing the certificate.
mhcli ssl:domains:list
This lists domains that are already present in your SSL certificate.
mhcli logs:varnish:filter --{filter}={value}
This command contains predefined filters to parse the Varnish logs. It is used to simplify the use of the varnishlog
command. All filters can be chained to make logging as specific as possible. In the next section, you can find some real life use cases.
mhcli logs:access:filter --{filter}={value}
This command filters the access logs (HaProxy or Apache) and creates a list showing top clients by IP or a list showing top visited URL paths.
Use cases / pitfalls
Continuous Integration
When you want to test your code per feature branch, it can come in handy to have appropriate domains to visit (for example featurexxx.my-company.dev). When building your feature, you can add the certificate with:
mhcli ssl:domains:add featurexxx.my-company.dev
When your tests are done, and you clean up the domains, you should always delete the domain from the certificate before deleting the domains from your DNS server:
mhcli ssl:domains:remove featurexxx.my-company.dev
If your CI does not know what domains are added, you can work with 1 fixed domain and remove all others with the help of:
mhcli ssl:domains:list
Varnish Debugging
To prevent too much noise when debugging Varnish, you can start by filtering the logs with your own IP, this comes in handy when you can reproduce the problem at hand.
mhcli logs:varnish:filter --ip='xxx.xxx.x.x'
If you have a large web application with multiple domains, and you (for example) want to revise the hash of a single page, you can use the --path
and --domain
filter. In some cases, you might even want to chain this with the --ip
filter.
mhcli logs:varnish:filter --path='/product-xx' --domain='my-company.com'