1
0
mirror of https://github.com/1C-Company/docker_fresh.git synced 2025-07-15 01:24:20 +02:00

Адаптировал скрипты для новых версий платформы fix #14 (#15)

* update from https://github.com/1C-Company/docker_fresh (#21)

* renew sert

* renew sert

* renew sert

* renew sert

* Исправил опечатки в Readme

* renew sert

* renew sert

Co-authored-by: Юрий <karnilaev@users.noreply.github.com>

* Адаптировал скрипты для новых версий платформы (#22)

Co-authored-by: Юрий <karnilaev@users.noreply.github.com>
This commit is contained in:
WizaXxX
2021-03-12 22:11:58 +03:00
committed by GitHub
parent 78502720fa
commit 81199f3365
6 changed files with 57 additions and 30 deletions

View File

@ -77,7 +77,7 @@ services:
- ./mnt:/mnt - ./mnt:/mnt
- /tmp/.aksusb:/tmp/.aksusb - /tmp/.aksusb:/tmp/.aksusb
- ../licenses_1c:/var/1C/licenses - ../licenses_1c:/var/1C/licenses
- ../conf/core:/opt/1C/v8.3/x86_64/conf - ../conf/core:PATH_TO_1C_REPLACEconf
ports: ports:
- 1540-1541:1540-1541 - 1540-1541:1540-1541
@ -92,11 +92,11 @@ services:
image: fresh/core image: fresh/core
hostname: ras.HOSTNAMEREPLACE hostname: ras.HOSTNAMEREPLACE
container_name: ras.HOSTNAMEREPLACE container_name: ras.HOSTNAMEREPLACE
command: /opt/1C/v8.3/x86_64/ras cluster --port=1545 srv:1540 command: PATH_TO_1C_REPLACEras cluster --port=1545 srv:1540
volumes: volumes:
- ./artifacts/ras/log:/var/log/1c - ./artifacts/ras/log:/var/log/1c
- ./mnt:/mnt - ./mnt:/mnt
- ../images/core/conf/logcfg.xml:/opt/1C/v8.3/x86_64/conf/logcfg.xml - ../images/core/conf/logcfg.xml:PATH_TO_1C_REPLACEconf/logcfg.xml
ports: ports:
- 1545:1545 - 1545:1545

View File

@ -12,6 +12,8 @@ import time
import uuid import uuid
path_to_1c = ''
# define regexps # define regexps
regex_process_pid = re.compile(r'/([^/.]+?)\.(\d+?)\.(\d+?)\.core') regex_process_pid = re.compile(r'/([^/.]+?)\.(\d+?)\.(\d+?)\.core')
regex_offset = re.compile(r'#0\s+?([\dxa-f]+?)\s') regex_offset = re.compile(r'#0\s+?([\dxa-f]+?)\s')
@ -31,6 +33,10 @@ def run_shell(cmd):
p = subprocess.Popen(cmd, shell=True, stdin=pipe, stdout=pipe, stderr=pipe, close_fds=True, cwd='/') p = subprocess.Popen(cmd, shell=True, stdin=pipe, stdout=pipe, stderr=pipe, close_fds=True, cwd='/')
return p.stdout.read(), p.stderr.read() return p.stdout.read(), p.stderr.read()
def run_shell_get_stdout(cmd):
pipe = subprocess.PIPE
p = subprocess.Popen(cmd, shell=True, stdin=pipe, stdout=pipe, stderr=pipe, close_fds=True, cwd='/')
return p.stdout.read()
def run_shell_get_result(cmd): def run_shell_get_result(cmd):
result = subprocess.call(cmd, shell=True) result = subprocess.call(cmd, shell=True)
@ -43,6 +49,14 @@ def check_size_static(core_file):
size_2 = os.path.getsize(core_file) size_2 = os.path.getsize(core_file)
return size_1 == size_2 return size_1 == size_2
def get_path_to_1c():
global path_to_1c
if path_to_1c == '':
result = run_shell_get_stdout("find / -name '1cv8c' | sed 's/1cv8c//g' | sed 's/\.\/opt/\/opt/g'")
path_to_1c = result.decode('utf-8').strip()
return path_to_1c
# END helper functions-------------------------------------------------------------------------------------------------- # END helper functions--------------------------------------------------------------------------------------------------
# BEGIN prepare date---------------------------------------------------------------------------------------------------- # BEGIN prepare date----------------------------------------------------------------------------------------------------
@ -58,7 +72,7 @@ def get_pid_process_ctime(core_file):
def get_platform_offset(core_file, process): def get_platform_offset(core_file, process):
# run gdb for getting offset of core # run gdb for getting offset of core
cmd = 'echo -e "bt\nexit" | gdb /opt/1C/v8.3/x86_64/' + process + ' ' + core_file cmd = 'echo -e "bt\nexit" | gdb ' + get_path_to_1c() + process + ' ' + core_file
(gdb_result, gdb_error) = run_shell(cmd) (gdb_result, gdb_error) = run_shell(cmd)
if not gdb_result: if not gdb_result:
@ -73,7 +87,7 @@ def get_platform_offset(core_file, process):
offset = rez.groups()[0] offset = rez.groups()[0]
offset = offset[6:-1] offset = offset[6:-1]
# getting platform version # getting platform version
cmd = 'strings /opt/1C/v8.3/x86_64/' + process + """ | grep -oP '[8-9]\.[3-90]\.\d\d?\.\d{2,4}' """ cmd = 'strings ' + get_path_to_1c() + process + """ | grep -oP '[8-9]\.[3-90]\.\d\d?\.\d{2,4}' """
(ver_result, ver_error) = run_shell(cmd) (ver_result, ver_error) = run_shell(cmd)
if ver_result: if ver_result:
platform = ver_result.strip() platform = ver_result.strip()
@ -105,7 +119,7 @@ def make_libs_tar(core_file, process):
if os.path.exists(libs_file): if os.path.exists(libs_file):
os.remove(libs_file) os.remove(libs_file)
cmd = """echo -e "info shared\nq" | """ cmd = """echo -e "info shared\nq" | """
cmd += """ gdb /opt/1C/v8.3/x86_64/""" + process + " " + core_file + """ 2>/dev/null | """ cmd += """ gdb """ + get_path_to_1c() + process + " " + core_file + """ 2>/dev/null | """
cmd += """ grep 0x0000 | grep -v /opt/1C/v8.3 | grep -v ?? | perl -alne 'print $F[-1]' | """ cmd += """ grep 0x0000 | grep -v /opt/1C/v8.3 | grep -v ?? | perl -alne 'print $F[-1]' | """
cmd += """ while read file; do tar --dereference --append -f """ + libs_file + """ $file 2> /dev/null ; done""" cmd += """ while read file; do tar --dereference --append -f """ + libs_file + """ $file 2> /dev/null ; done"""
stdout, stderr = run_shell(cmd) stdout, stderr = run_shell(cmd)

View File

@ -2,15 +2,17 @@
set -e set -e
platform_path=$(find / -name "1cv8c" | sed 's/1cv8c//g' | sed 's/\.\/opt/\/opt/g')
if [ "$1" = 'srv' ] if [ "$1" = 'srv' ]
then then
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS} chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ragent -debug -http /d ${COREDATA} exec gosu usr1cv8 ${platform_path}ragent -debug -http /d ${COREDATA}
elif [ "$1" = 'srv+cli' ] elif [ "$1" = 'srv+cli' ]
then then
ulimit -c unlimited ulimit -c unlimited
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS} chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ragent -debug -http /d ${COREDATA} & exec gosu usr1cv8 ${platform_path}ragent -debug -http /d ${COREDATA} &
status=$? status=$?
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then
echo "Failed to start ragent: $status" echo "Failed to start ragent: $status"
@ -37,7 +39,7 @@ then
elif [ "$1" = 'ras' ] elif [ "$1" = 'ras' ]
then then
chown -R usr1cv8:grp1cv8 ${CORELOGS} chown -R usr1cv8:grp1cv8 ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ras cluster exec gosu usr1cv8 ${platform_path}ras cluster
elif [ "$1" = 'cli' ] elif [ "$1" = 'cli' ]
then then
chown -R usr1cv8:grp1cv8 ${CORELOGS} chown -R usr1cv8:grp1cv8 ${CORELOGS}
@ -54,7 +56,7 @@ elif [ "$1" = 'agent' ]
then then
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS} ${AGENTBASEDIR} chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS} ${AGENTBASEDIR}
exec /usr/bin/Xvfb :99 -screen 0 1680x1050x24 -shmem & exec /usr/bin/Xvfb :99 -screen 0 1680x1050x24 -shmem &
exec /opt/1C/v8.3/x86_64/1cv8 DESIGNER /AgentMode /IBConnectionString "${INFOBASECONNECTIONSTRING}" /AgentBaseDir "${AGENTBASEDIR}" /AgentSSHHostKey "/id_rsa.key" /Visible /AgentListenAddress 0.0.0.0 exec ${platform_path}1cv8 DESIGNER /AgentMode /IBConnectionString "${INFOBASECONNECTIONSTRING}" /AgentBaseDir "${AGENTBASEDIR}" /AgentSSHHostKey "/id_rsa.key" /Visible /AgentListenAddress 0.0.0.0
fi fi
exec "$@" exec "$@"

View File

@ -1,15 +1,5 @@
cd /out_files cd /out_files
DISTR_FILE_VERSION=$(ls | grep "client" | grep -Eo "[0-9]+\_[0-9]+\_[0-9]+\_[0-9]+")
DISTR_VERSION=$(ls | grep "client" | grep -Eo "[0-9]+\_[0-9]+\_[0-9]+\_[0-9]+" | sed 's/_/./g')
DISTR_VER1=$(echo $DISTR_VERSION | cut -d '.' -f 1-3)
DISTR_VER2=$(echo $DISTR_VERSION | cut -d '.' -f 4)
common_file_name=1C_Enterprise83-common-$DISTR_VER1-$DISTR_VER2.x86_64.rpm tar -xvf client*.rpm64.tar.gz --exclude "*thin*.rpm" --exclude "*nls*.rpm" --exclude "license-tools" -C /main_dir/distr
server_file_name=1C_Enterprise83-server-$DISTR_VER1-$DISTR_VER2.x86_64.rpm tar -xvf rpm64_*.tar.gz --exclude "*crs*.rpm" --exclude "*nls*.rpm" -C /main_dir/distr
ws_file_name=1C_Enterprise83-ws-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
client_file_name=1C_Enterprise83-client-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
tar -xvf client_$DISTR_FILE_VERSION.rpm64.tar.gz $client_file_name -C /main_dir/distr
tar -xvf rpm64_$DISTR_FILE_VERSION.tar.gz $common_file_name $server_file_name $ws_file_name -C /main_dir/distr
tar -xvf rpm64_$DISTR_FILE_VERSION.tar.gz "license-tools" -C /main_dir/distr/

View File

@ -1,10 +1,12 @@
import pathlib import pathlib
import os import os
path_to_1c = ''
sep = str(os.path.sep) sep = str(os.path.sep)
this_path = str(pathlib.Path().absolute()) + sep this_path = str(pathlib.Path().absolute()) + sep
distr_path = this_path + 'distr' + sep distr_path = this_path + 'distr' + sep
def replace_sep(path): def replace_sep(path):
return path.replace('/', sep) return path.replace('/', sep)
@ -35,7 +37,7 @@ def web_publish_command(host_name, conf_name, internal, descriptor, base_name=''
command.append('docker') command.append('docker')
command.append('exec') command.append('exec')
command.append('web.' + host_name) command.append('web.' + host_name)
command.append('/opt/1C/v8.3/x86_64/webinst') command.append('{}webinst'.format(path_to_1c))
command.append('-apache24') command.append('-apache24')
command.append('-wsdir') command.append('-wsdir')
command.append(prefix + '/' + conf_name) command.append(prefix + '/' + conf_name)
@ -62,7 +64,7 @@ def create_ib_command(host_name, ib_name, file_name, job_block, action):
command.append('exec') command.append('exec')
command.append('-t') command.append('-t')
command.append('srv.' + host_name) command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8') command.append('{}1cv8'.format(path_to_1c))
command.append('CREATEINFOBASE') command.append('CREATEINFOBASE')
command.append('"Srvr=srv;Ref={0};DBMS=PostgreSQL;DBSrvr=/tmp/postgresql/socket;DB={0};DBUID=postgres;LicDstr=Y;Locale=ru_RU;CrSQLDB=Y;SchJobDn={1};"'.format( command.append('"Srvr=srv;Ref={0};DBMS=PostgreSQL;DBSrvr=/tmp/postgresql/socket;DB={0};DBUID=postgres;LicDstr=Y;Locale=ru_RU;CrSQLDB=Y;SchJobDn={1};"'.format(
ib_name, job_block)) ib_name, job_block))
@ -77,7 +79,7 @@ def install_control_ext_command(host_name, ib_name, action):
command.append('exec') command.append('exec')
command.append('-t') command.append('-t')
command.append('srv.' + host_name) command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8') command.append('{}1cv8'.format(path_to_1c))
command.append('DESIGNER') command.append('DESIGNER')
command.append('/S') command.append('/S')
command.append('"srv\\{}"'.format(ib_name)) command.append('"srv\\{}"'.format(ib_name))
@ -95,7 +97,7 @@ def install_sm_ext_command(host_name, ib_name, action):
command.append('exec') command.append('exec')
command.append('-t') command.append('-t')
command.append('srv.' + host_name) command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8') command.append('{}1cv8'.format(path_to_1c))
command.append('DESIGNER') command.append('DESIGNER')
command.append('/S') command.append('/S')
command.append('"srv\\{}"'.format(ib_name)) command.append('"srv\\{}"'.format(ib_name))
@ -113,7 +115,7 @@ def install_ext_command(host_name, ib_name, action):
command.append('exec') command.append('exec')
command.append('-t') command.append('-t')
command.append('srv.' + host_name) command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8') command.append('{}1cv8'.format(path_to_1c))
command.append('DESIGNER') command.append('DESIGNER')
command.append('/S') command.append('/S')
command.append('"srv\\{}"'.format(ib_name)) command.append('"srv\\{}"'.format(ib_name))
@ -131,7 +133,7 @@ def disable_safe_mode(host_name, ib_name, action):
command.append('exec') command.append('exec')
command.append('-t') command.append('-t')
command.append('srv.' + host_name) command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8') command.append('{}1cv8'.format(path_to_1c))
command.append('ENTERPRICE') command.append('ENTERPRICE')
command.append('/S') command.append('/S')
command.append('"srv\\{}"'.format(ib_name)) command.append('"srv\\{}"'.format(ib_name))
@ -234,3 +236,8 @@ def get_host_name(argv):
exit(1) exit(1)
host_index = argv.index('-h') host_index = argv.index('-h')
return argv[host_index + 1] return argv[host_index + 1]
def init(path):
global path_to_1c
path_to_1c = path

View File

@ -21,6 +21,7 @@ docker_compose_str = 'docker-compose -f workdir/docker-compose.yml '
work_dir = '/out_files/workdir/' work_dir = '/out_files/workdir/'
work_dir_other = work_dir + 'mnt/other-files/' work_dir_other = work_dir + 'mnt/other-files/'
local_work_dir = helper.replace_sep(helper.this_path + 'workdir/') local_work_dir = helper.replace_sep(helper.this_path + 'workdir/')
path_to_1c = ''
class colors: class colors:
@ -91,7 +92,7 @@ def print_description(function_to_decorate):
task.join() task.join()
progress_thread.stop() progress_thread.stop()
while progress_thread.isAlive(): while progress_thread.is_alive():
time.sleep(0.2) time.sleep(0.2)
if not task.is_good: exit(1) if not task.is_good: exit(1)
@ -272,6 +273,7 @@ def renew_docker_compose():
call('cp /out_files/docker-compose_pattern.yml /out_files/workdir/docker-compose.yml') call('cp /out_files/docker-compose_pattern.yml /out_files/workdir/docker-compose.yml')
call('sh -c "sed -i \'s/HOSTNAMEREPLACE/{}/\' {}/*.yml"'.format(host_name, work_dir)) call('sh -c "sed -i \'s/HOSTNAMEREPLACE/{}/\' {}/*.yml"'.format(host_name, work_dir))
call('sh -c "sed -i \'s/PATH_TO_1C_REPLACE/{}/\' {}/*.yml"'.format(path_to_1c.replace('/','\/'), work_dir))
@print_description @print_description
@ -425,6 +427,16 @@ def down_containers():
call(docker_compose_str + 'down', remote=False) call(docker_compose_str + 'down', remote=False)
@print_description
def get_path_to_1c():
"""Getting path to 1C"""
global path_to_1c
cmd = "docker run --rm fresh/core sh -c \"find / -name '1cv8c' | sed 's/1cv8c//g'\""
pipe = subprocess.PIPE
p = subprocess.Popen(cmd, shell=True, stdin=pipe, stdout=pipe, stderr=pipe, close_fds=True)
path_to_1c = p.stdout.read().decode('utf-8').strip()
print('path to 1C: ' + path_to_1c)
global_start_time = datetime.now() global_start_time = datetime.now()
print('{}Fresh is starting{} at {}'.format(colors.GREEN, colors.WHITE, global_start_time)) print('{}Fresh is starting{} at {}'.format(colors.GREEN, colors.WHITE, global_start_time))
@ -434,6 +446,8 @@ new_server = '-new' in sys.argv
global_debug = '-debug' in sys.argv global_debug = '-debug' in sys.argv
set_full_host_name(new_server) set_full_host_name(new_server)
get_path_to_1c()
helper.init(path_to_1c)
if new_server: if new_server:
renew_workdir() renew_workdir()