StefanThank you. I should have said this has been working fine for years and years until Ubuntu 2022.04 on a new droplet running Apache/2.4.52
I will refactor it one day - especially if the script is implicated. But I think I have to learn how to use lsof first!
Cheers Mike On 30/11/2022 1:44 am, Stefan Ram wrote:
"Weatherby,Gerard"<gweathe...@uchc.edu> writes:Do any of you Python folks see any blunders in the above code along the lines of not letting go of py files or static assets?No, sorry. But I had to refactor it. *Warning* The following code is not intended to be executed, it is just intended to be read by humans. It was not tested and, therefore, it probably contains errors. If executed, it may cause destruction such as deletions of files etc. Stefan Ram (I) does not claim any copyright for his modifications. def attempt( task, command ): if trycmd( command, log ): print( f'task "{task}" failed.' ) return False # failure else: return True # success def main(): with open( fetchlog, 'a' )as log_: global log log = log_ remove_site() del log def remove_site(): log.write( f"\n\nFetching {tag}" ) if attempt( "remove site", f"sudo rm -Rf {site_root}", log ): get_source() def get_source(): if attempt( "get source", f"sudo svn export --force --username {usr} --password {pw} {svn_repo} {site_root}" ): install_requirements() def install_requirements(): if attempt( "install requirements", f"sudo -H pip install -r {reqfile}" ): repo_migrations() def repo_migrations(): if attempt( "run any migrations shipped from the repo", f"sudo python3 {site_root}/manage.py migrate --noinput --settings={settings}" ): makemigrations() def makemigrations(): # shouldn't find anything if attempt( "makemigrations", f"sudo python3 {site_root}/manage.py makemigrations --noinput --settings={settings}" ): migrate() def migrate(): # should already be done if attempt( "migrate 2", f"sudo python3 {site_root}/manage.py migrate --noinput --settings={settings}" ): remove_static() def remove_static(): if attempt( "remove all static files from their Apache dir", f"sudo rm -Rf {static_root}/*" ): copy_static() def copy_static(): if attempt( "copy all static files to the Apache location", f"sudo python3 {site_root}/manage.py collectstatic --noinput --settings={settings}" ): set_permissions() def set_permissions(): if attempt( "set all permissions", f"sudo {scripts}/perms_{host}.sh" ): service_restart() def service_restart(): if attempt( "restart of Apache service", f"sudo service apache2 restart" ): log_success() def log_success(): log.write( f"\nFinish {tag}\n\n" ) # main() # sys.exit()
-- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Just ask and I'll send it to you. Your email software can handle signing.
OpenPGP_signature
Description: OpenPGP digital signature
-- https://mail.python.org/mailman/listinfo/python-list