2

My Magento 2 Website is already live. In local, i have developed module which contains JS/CSS/Email/etc... Need to upload on Live.

But LIVE website should not affect, as there are So many users visiting Site. Would not like to make site under Maintenance.

On LIVE Website it's already in Production Mode.

How to run below commands in a background?

  php bin/magento setup:upgrade
  php bin/magento module:enable MODULE_NAME
  php bin/magento cache:flush

Is there any solution for this? It always annoying that you have to upload Module & Ur JS/CSS Changes then u have to run 4-5 commands which will affect live running website.

We can't put so many time our LIVE website under Maintenance Mode or can't face Downtime of Website.

2

You should use a different deploy process, we currently use Fabric, it creates symlinks for certain folders so you could go back to the previous version and the shop is set to maintenance for a very small amount of time. I would recommend deploying within the hour that the shop has just a few users.

More information about fabric.

Our deploy task, this might help you:

Sorry for editing the other answer:

@task
def deploy():
    print('Deploying ' + colors.blue(env.git_branch) + ' branch to ' + colors.blue(env.name) + ' environment at ' + colors.blue(env.domain) + ' on path ' + colors.blue(env.deploy_to))

    if not confirm('Continue?', default=False):
        return

    notify(':loudspeaker: _%s_ started deploying the *%s* branch to the *%s* environment at %s :metal:' % (env.local_user, env.git_branch, env.name, env.domain))

    try:
        if files.exists(env.release_dir):
            error('"%s" directory already exists!' % env.release_dir)

        check_for_clean_current_dir()

        update_repo_dir()

        check_or_create_shared_files(create=False)

        run('mkdir -p "%s"' % env.release_dir)
        run('git clone "%s" "%s"' % (env.repo_dir, env.release_dir))

        symlink_shared_files_into_release()

        with cd(env.release_dir):
            run('tools/composer.phar install --prefer-dist --no-dev')
            run('npm install --production')
            cleanup_files_after_installation()
            run('git checkout pub/.htaccess')

            run('php bin/magento deploy:mode:set --skip-compilation production')
            run('php bin/magento setup:di:compile')
            run('touch pub/static/deployed_version.txt')  # workaround for new bug/feature introduced in M2.1.1, keep in here until https://github.com/magento/magento2/issues/6426 is fixed
            run('php bin/magento setup:static-content:deploy %s %s' % (' '.join(['--theme %s' % t for t in conf.adminhtml_themes]), ' '.join(conf.adminhtml_languages)))
            run('php bin/magento setup:static-content:deploy %s %s' % (' '.join(['--theme %s' % t for t in conf.frontend_themes]),  ' '.join(conf.frontend_languages)))
            run('php bin/magento maintenance:enable')

            fix_file_permissions()

        timestamp_before_going_down = time.time()
        symlink_new_release_to_current()
        warn('\n!! MAINTENANCE MODE ENABLED - WEBSHOP IS DOWN !!\n')

        with cd(env.current_dir):
            run('php bin/magento setup:upgrade --keep-generated')
            local('curl --silent --insecure %sopcache_clear.php?%s' % (env.domain, urllib.urlencode({'secret': conf.opcache_secret})))
            run('php bin/magento maintenance:disable')
            run('php bin/magento cache:flush')  # there are reports from colleagues that indicate we need to run this, even though var/cache shouldn't contain old caches at this point
            timestamp_after_going_down = time.time()

            total_time_down = timestamp_after_going_down - timestamp_before_going_down
            print(colors.green('\n!! MAINTENANCE MODE DISABLED - WEBSHOP IS AVAILABLE AGAIN (downtime: %.2f seconds) !!\n' % total_time_down))

        # cleanup older releases, tnx to http://stackoverflow.com/a/34862475/145829
        with cd(env.releases_dir):
            run('ls -1tp | grep "/$" | tail -n +4 | tr "\\n" "\\0" | xargs -0 --no-run-if-empty rm -R --')

        notify(':tada: _%s_ finished deploying the *%s* branch to the *%s* environment at %s :thumbsup:' % (env.local_user, env.git_branch, env.name, env.domain))
    except:
        print(colors.red('\nSomething went wrong, please check above output to figure out what caused it!\n'))
        notify(':bangbang: _%s_ *failed* to deploy the *%s* branch to the *%s* environment at %s :collision:' % (env.local_user, env.git_branch, env.name, env.domain))
  • Currently we are doing that, when Minimum Users on Site we Up the Changes – Ankit Shah Dec 8 '16 at 8:18
  • I added our deploy task from the fabric file, this might help you – Vlad Patru Dec 8 '16 at 8:26
  • We tried some capistrano versions of the deploy but the shop was always in maintainance in the compilation time – Vlad Patru Dec 8 '16 at 8:43
  • Ok. So for you this one is best. No need to say Sorry for Editing. If it's useful then sure can edit as many times as u want. – Ankit Shah Dec 8 '16 at 8:48
0

Can you do clone of production with online database replication?

Currently magento 2 doesn't have tools for background update. Use the maintenance mode http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-subcommands-maint.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.