mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-12-23 18:48:58 +00:00
Merge pull request #357 from sahil28297/org_develop
feat: add drop site command to worker
This commit is contained in:
commit
c057804382
@ -10,3 +10,4 @@ COMMON_SITE_CONFIG_FILE = 'common_site_config.json'
|
||||
DATE_FORMAT = "%Y%m%d_%H%M%S"
|
||||
RDS_DB = 'rds_db'
|
||||
RDS_PRIVILEGES = "SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES"
|
||||
ARCHIVE_SITES_PATH = '/home/frappe/frappe-bench/sites/archive_sites'
|
39
build/common/commands/drop.py
Normal file
39
build/common/commands/drop.py
Normal file
@ -0,0 +1,39 @@
|
||||
import os
|
||||
import frappe
|
||||
|
||||
from frappe.commands.site import _drop_site
|
||||
from constants import ARCHIVE_SITES_PATH
|
||||
from utils import get_password
|
||||
|
||||
|
||||
def main():
|
||||
site_name = os.environ.get("SITE_NAME", 'site1.localhost')
|
||||
db_root_username = os.environ.get("DB_ROOT_USER", 'root')
|
||||
mariadb_root_password = get_password("MYSQL_ROOT_PASSWORD", 'admin')
|
||||
postgres_root_password = get_password("POSTGRES_PASSWORD")
|
||||
db_root_password = mariadb_root_password
|
||||
|
||||
if postgres_root_password:
|
||||
db_root_password = postgres_root_password
|
||||
|
||||
force = True if os.environ.get("FORCE", None) else False
|
||||
no_backup = True if os.environ.get("NO_BACKUP", None) else False
|
||||
frappe.init(site_name, new_site=True)
|
||||
|
||||
_drop_site(
|
||||
site=site_name,
|
||||
root_login=db_root_username,
|
||||
root_password=db_root_password,
|
||||
archived_sites_path=ARCHIVE_SITES_PATH,
|
||||
force=force,
|
||||
no_backup=no_backup
|
||||
)
|
||||
|
||||
if frappe.redis_server:
|
||||
frappe.redis_server.connection_pool.disconnect()
|
||||
|
||||
exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -149,6 +149,18 @@ elif [ "$1" = 'new' ]; then
|
||||
python /home/frappe/frappe-bench/commands/new.py
|
||||
fi
|
||||
|
||||
elif [ "$1" = 'drop' ]; then
|
||||
checkConfigExists
|
||||
checkConnection
|
||||
if [[ -z "$RUN_AS_ROOT" ]]; then
|
||||
su frappe -c ". /home/frappe/frappe-bench/env/bin/activate \
|
||||
&& python /home/frappe/frappe-bench/commands/drop.py"
|
||||
exit
|
||||
else
|
||||
. /home/frappe/frappe-bench/env/bin/activate
|
||||
python /home/frappe/frappe-bench/commands/drop.py
|
||||
fi
|
||||
|
||||
elif [ "$1" = 'migrate' ]; then
|
||||
|
||||
su frappe -c ". /home/frappe/frappe-bench/env/bin/activate \
|
||||
|
@ -409,6 +409,20 @@ docker run \
|
||||
--network frappebench00_default \
|
||||
frappe/erpnext-worker:edge console pgsql.localhost
|
||||
|
||||
echo -e "\e[1m\e[4mCheck drop site: test.localhost (mariadb)\e[0m"
|
||||
docker run \
|
||||
-e SITE_NAME=test.localhost \
|
||||
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network frappebench00_default \
|
||||
frappe/erpnext-worker:edge drop
|
||||
|
||||
echo -e "\e[1m\e[4mCheck drop site: pgsql.localhost (pgsql)\e[0m"
|
||||
docker run \
|
||||
-e SITE_NAME=pgsql.localhost \
|
||||
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
--network frappebench00_default \
|
||||
frappe/erpnext-worker:edge drop
|
||||
|
||||
echo -e "\e[1m\e[4mCheck bench --help\e[0m"
|
||||
docker run \
|
||||
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
|
||||
|
Loading…
Reference in New Issue
Block a user