This week we have deployed a new command on all Hypernodes which exposes the capability of restarting or reloading a select number of services to the
app user. The command is
hypernode-servicectl and it takes as arguments an action (restart or reload) and a service (Nginx, php7.1-fpm, etc).
Because Hypernode is managed cloud hosting for Magento there generally should be no reason for users to restart services for the purpose of stability. We have various mechanisms of autorecovery in place to make sure that if for some reason any of the crucial system daemons are not operating properly they will be automatically troubleshot and restarted if it looks like that would be the quickest strategy to resolve any service degradation. But even though there is no reason to manually restart services for operational concerns on Hypernode, there could be situations in which it might make sense to restart them to resolve some userspace issues.
For example, restarting PHP is a quick and easy way to kill all running requests. This could be helpful if you are debugging long running or cache heavy PHP requests. You can kill individual FPM workers to achieve the same, but for some peace of mind, knowing without a doubt that the entire daemon was restarted could go a long way. Other times you might want to override a couple of PHP settings like the
max_execution_time and make sure your changes have been activated. In those cases a graceful restart would make sense.
Free up memory
Another common use-case is to free up some cached memory on nodes with a limited amount of RAM before executing a resource intensive task on the server. Especially on our Magento Start and Grow plans memory usage can become an issue over the course of a shop’s development lifecycle. When the server is hitting its limits, a heavy cron could cause the memory management software on the Hypernode to kill less essential processes in order to preserve the ability to serve requests to customers. A well timed service restart could help you squeeze out that extra bit of capacity by sacrificing full caches for some temporary extra breathing room.
The command can be executed as
help menu displays the available options.
$ hypernode-servicectl --help
usage: hypernode-servicectl [-h] [--version] [action] [service [service ...]]
Control Hypernode services
action desired action on services (restart|reload)
service target service, (mysql|nginx|php7.1-fpm)
-h, --help show this help message and exit
--version show program's version number and exit
For example, restarting PHP would look like:
app@83f01a-vdloo-magweb-cmbl:~$ hypernode-servicectl restart php7.1-fpm
If you are running a different version of PHP (like 5.6) you need to specify that instead (e.g.
hypernode-servicectl restart php5.6-fpm). The available PHP version for your system will show up in the help menu.
When Varnish is enabled for your Hypernode it will show up in the help menu as well as an available service to be restarted. If it is not available the command will inform you and return exit code 64 (EX_USAGE).
$ hypernode-servicectl restart varnish
service "varnish" is not available.
$ echo $?
You can both restart and reload services. A restart will stop the relevant processes and start new ones, a reload will ordinarily keep the service running but re-reads the configuration files. The exact behavior is implementation specific to the daemon your are reloading however.
Note that you will not be able to restart or reload services when critical Hypernode system processes are running. At those moments the command will print
Not allowed to restart or reload services at this time and exit with return code 69 (EX_UNAVAILABLE). An example of such a scenario is when a Hypernode is being upgrade to a larger instance and the services are temporarily stopped to perform the data synchronisation.
This command will become available on all Hypernodes in the coming week.