mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-12-23 02:28:57 +00:00
feat: add drop site command to worker
This commit is contained in:
parent
c104d027f9
commit
94a37d68e3
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user