Created
March 4, 2020 12:07
-
-
Save gamorales/32722f8827d0e7b0c16139d7749b2b7b to your computer and use it in GitHub Desktop.
Verifying if odoo (or any process) is running.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
try: | |
resultado = subprocess.check_output("sudo systemctl status odoo12 | grep 'Active: failed'", shell=True) | |
if "Active: failed" in resultado: | |
subprocess.check_output("sudo systemctl stop odoo12", shell=True) | |
subprocess.check_output("sudo systemctl start odoo12", shell=True) | |
print("activado 1") | |
else: | |
resultado = subprocess.check_output("sudo systemctl status odoo12 | grep inactive", shell=True) | |
if "inactive" in resultado: | |
subprocess.check_output("sudo systemctl stop odoo12", shell=True) | |
subprocess.check_output("sudo systemctl start odoo12", shell=True) | |
print("activado 2") | |
except Exception as e: | |
print(e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment