Magento 2: Run setup:di:compile a Specific Module
You can do this by follow this step :
Go to :
/var/www/html/YourMagento/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php
Find this line :
$modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
Replace this below line and add path of the module which you want to compile like this :
$modulePaths = ['CompanyName_ModuleName' => '/var/www/html/YourMagento/app/code/CompanyName/ModuleName'];
Make sure module register with thisCompanyName_ModuleName
in registration.php
file.
It's temporary solution for di compile single module. Remove di generated module folder and refresh cache.
Hope, It will helpful for you.
Reference
If your focus is to try to contain as well as possible the downtime of your production, the below may help:
You could clone your codebase on the same server and separate folder (clone basically).
Once both environments would coexist, you can deploy static content on the clone without penalising the production environment uptime.
Finally, when the deploy is complete, you could either symlink the pub/static folder or just rsync. Of course, this may be done with a script.