mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +00:00
Merge branch 'develop' into bench-cli-fix
This commit is contained in:
commit
e345d18c7d
@ -27,7 +27,7 @@ def cli():
|
|||||||
command = " ".join(sys.argv)
|
command = " ".join(sys.argv)
|
||||||
|
|
||||||
change_working_directory()
|
change_working_directory()
|
||||||
logger = setup_logging() or logging.getLogger(bench.PROJECT_NAME)
|
logger = setup_logging()
|
||||||
logger.info(command)
|
logger.info(command)
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] not in ("src", ):
|
if len(sys.argv) > 1 and sys.argv[1] not in ("src", ):
|
||||||
|
@ -111,7 +111,7 @@ def download_translations():
|
|||||||
download_translations_p()
|
download_translations_p()
|
||||||
|
|
||||||
|
|
||||||
@click.command('renew-lets-encrypt', help="Renew Let's Encrypt certificate")
|
@click.command('renew-lets-encrypt', help="Sets Up latest cron and Renew Let's Encrypt certificate")
|
||||||
def renew_lets_encrypt():
|
def renew_lets_encrypt():
|
||||||
from bench.config.lets_encrypt import renew_certs
|
from bench.config.lets_encrypt import renew_certs
|
||||||
renew_certs()
|
renew_certs()
|
||||||
|
@ -87,10 +87,16 @@ def run_certbot_and_setup_ssl(site, custom_domain, bench_path, interactive=True)
|
|||||||
|
|
||||||
def setup_crontab():
|
def setup_crontab():
|
||||||
job_command = '/opt/certbot-auto renew -a nginx --post-hook "systemctl reload nginx"'
|
job_command = '/opt/certbot-auto renew -a nginx --post-hook "systemctl reload nginx"'
|
||||||
|
job_comment = 'Renew lets-encrypt every month'
|
||||||
|
print("Setting Up cron job to {0}".format(job_comment))
|
||||||
|
|
||||||
system_crontab = CronTab(user='root')
|
system_crontab = CronTab(user='root')
|
||||||
if job_command not in str(system_crontab):
|
|
||||||
job = system_crontab.new(command=job_command, comment="Renew lets-encrypt every month")
|
for job in system_crontab.find_comment(comment=job_comment): # Removes older entries
|
||||||
job.day.on(1)
|
system_crontab.remove(job)
|
||||||
|
|
||||||
|
job = system_crontab.new(command=job_command, comment=job_comment)
|
||||||
|
job.setall('0 0 */1 * *') # Run at 00:00 every day-of-month
|
||||||
system_crontab.write()
|
system_crontab.write()
|
||||||
|
|
||||||
|
|
||||||
@ -113,10 +119,13 @@ def get_certbot_path():
|
|||||||
|
|
||||||
|
|
||||||
def renew_certs():
|
def renew_certs():
|
||||||
|
# Needs to be run with sudo
|
||||||
click.confirm('Running this will stop the nginx service temporarily causing your sites to go offline\n'
|
click.confirm('Running this will stop the nginx service temporarily causing your sites to go offline\n'
|
||||||
'Do you want to continue?',
|
'Do you want to continue?',
|
||||||
abort=True)
|
abort=True)
|
||||||
|
|
||||||
|
setup_crontab()
|
||||||
|
|
||||||
service('nginx', 'stop')
|
service('nginx', 'stop')
|
||||||
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
||||||
service('nginx', 'start')
|
service('nginx', 'start')
|
||||||
|
@ -443,10 +443,13 @@ def setup_logging(bench_path='.'):
|
|||||||
logging.Logger.log = logv
|
logging.Logger.log = logv
|
||||||
|
|
||||||
if os.path.exists(os.path.join(bench_path, 'logs')):
|
if os.path.exists(os.path.join(bench_path, 'logs')):
|
||||||
logger = logging.getLogger(bench.PROJECT_NAME)
|
|
||||||
log_file = os.path.join(bench_path, 'logs', 'bench.log')
|
log_file = os.path.join(bench_path, 'logs', 'bench.log')
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
|
||||||
hdlr = logging.FileHandler(log_file)
|
hdlr = logging.FileHandler(log_file)
|
||||||
|
else:
|
||||||
|
hdlr = logging.NullHandler()
|
||||||
|
|
||||||
|
logger = logging.getLogger(bench.PROJECT_NAME)
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
||||||
hdlr.setFormatter(formatter)
|
hdlr.setFormatter(formatter)
|
||||||
logger.addHandler(hdlr)
|
logger.addHandler(hdlr)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
Loading…
Reference in New Issue
Block a user