Skip to content

Instantly share code, notes, and snippets.

@gamorales
Created March 4, 2020 12:07
Show Gist options
  • Save gamorales/32722f8827d0e7b0c16139d7749b2b7b to your computer and use it in GitHub Desktop.
Save gamorales/32722f8827d0e7b0c16139d7749b2b7b to your computer and use it in GitHub Desktop.
Verifying if odoo (or any process) is running.
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