Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 512f5ce14d | |||
| 9a3215524e | |||
| 84a8c1cb31 | |||
| 4774bd9005 | |||
| 59e7002a59 | |||
| 1387893a14 | |||
| 87e1a0610b | |||
| 6a6046050c | |||
| 0e23024aab | |||
| d32bf31f4a | |||
| 65c87f97e6 | |||
| ae79f940fb | |||
| 80ae780f02 | |||
| 5318b16b7f | |||
| 03c341cefb | |||
| db7ea93c6b |
+39
-8
@@ -6,6 +6,7 @@ declare -A git_repo_arr
|
||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvttpy.git
|
||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/ops.git
|
||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/research.git
|
||||
git_repo_arr[cvtt-rust]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvtt-rust.git
|
||||
|
||||
dist_root=/home/cvttdist/software/cvtt2
|
||||
dist_user=cvttdist
|
||||
@@ -48,13 +49,29 @@ while getopts ":p:b:i" opt; do
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
function confirm {
|
||||
confirm() {
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "--------------------------------"
|
||||
echo -n "Press <Enter> to continue" && read
|
||||
fi
|
||||
}
|
||||
|
||||
rust_binaries() {
|
||||
res=()
|
||||
for binname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("bin")) | .name'); do
|
||||
res+=("${binname}")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
rust_libraries() {
|
||||
res=()
|
||||
for libname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("lib")) | .name'); do
|
||||
res+=("lib${libname}.rlib")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo -n "Enter project [${prj}]: "
|
||||
read project
|
||||
@@ -149,6 +166,24 @@ cmd_arr+=("${Cmd}")
|
||||
Cmd="rm -rf .git"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
SourceLoc=../${project}
|
||||
if [ "${project}" == "cvtt-rust" ]; then
|
||||
|
||||
cmd_arr+=("cd ${prj_dir}")
|
||||
|
||||
cmd_arr+=("mkdir -p ${prj_dir}/dist/release")
|
||||
cmd_arr+=("cp release_version.txt ./dist/release")
|
||||
|
||||
jq_cmd="jq '.packages[] | select(.targets[].kind[] == \"bin\") | .name'"
|
||||
apps=$(cargo metadata --no-deps --format-version 1 --manifest-path=${prj_dir}/Cargo.toml | eval $jq_cmd | uniq)
|
||||
for app in ${apps[@]}; do
|
||||
app=${app//\"/} # remove quotes
|
||||
cmd_arr+=("cargo install --root ${prj_dir}/dist/release --path ${prj_dir}/apps/${app}")
|
||||
done
|
||||
|
||||
SourceLoc=${prj_dir}/dist/release
|
||||
fi
|
||||
|
||||
dist_path="${dist_root}/${project}/${release_version}"
|
||||
|
||||
for dist_loc in ${dist_locations}; do
|
||||
@@ -156,9 +191,9 @@ for dist_loc in ${dist_locations}; do
|
||||
dist_host=${dhp[0]}
|
||||
dist_port=${dhp[1]}
|
||||
Cmd="rsync -avzh"
|
||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path} && rsync\""
|
||||
Cmd="${Cmd} -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} ../${project} ${dist_user}@${dist_host}:${dist_path}/"
|
||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path}"
|
||||
Cmd="${Cmd} && rsync\" -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} $SourceLoc ${dist_user}@${dist_host}:${dist_path}/"
|
||||
cmd_arr+=("${Cmd}")
|
||||
done
|
||||
|
||||
@@ -179,8 +214,4 @@ do
|
||||
pwd && echo ${cmd} && eval ${cmd}
|
||||
done
|
||||
|
||||
echo "PROJECT ${project} **** P U L L N E W T A G S F R O M o r i g i n ****"
|
||||
echo "----"
|
||||
echo "(cd ${project}; git pull --tags; git pushall)"
|
||||
echo "----"
|
||||
echo "$0 Done ${project} ${release_version}"
|
||||
|
||||
File diff suppressed because one or more lines are too long
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -N <num_symbols> [-L <LogDir>] [-d <YYYYMMDD Date>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
is_container_running() {
|
||||
local container_name=$1
|
||||
|
||||
if [ "$(docker ps --filter "name=^/${container_name}$" --filter "status=running" -q)" ]; then
|
||||
return 0 # true
|
||||
else
|
||||
return 1 # false
|
||||
fi
|
||||
}
|
||||
|
||||
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
|
||||
|
||||
is_business_day() {
|
||||
dt=${1}
|
||||
|
||||
open_time=$(curl -s "${CalendarURL}&start=${dt}&end=${dt}" | jq '.[] | .open_time')
|
||||
if [ -n "${open_time}" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
export -f is_business_day
|
||||
|
||||
get_prev_business_day() {
|
||||
Start=${1}
|
||||
while true; do
|
||||
if is_business_day ${Start}; then
|
||||
break
|
||||
fi
|
||||
echo "${Start} is not business day in US" >&2
|
||||
Start=$(date -d "${Start} - 1 day" "+%Y-%m-%d")
|
||||
done
|
||||
echo ${Start}
|
||||
}
|
||||
export -f get_prev_business_day
|
||||
|
||||
# ----- Settings
|
||||
DockerRegistry=cloud21.cvtt.vpn:5500
|
||||
DockerImage=${DockerRegistry}/alpaca_hbar #:latest
|
||||
ContainerName=alpaca_hbar
|
||||
LogDir=/home/cvtt/prod/logs
|
||||
# ----- Settings
|
||||
|
||||
while getopts ":d:N:L:" opt; do
|
||||
case ${opt} in
|
||||
d )
|
||||
date_to_load=$OPTARG
|
||||
;;
|
||||
N )
|
||||
NumSymbols=$OPTARG
|
||||
;;
|
||||
L )
|
||||
LogDir=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if is_container_running "$ContainerName"; then
|
||||
echo "Container ${ContainerName} is already running."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [ -z "${date_to_load}" ]; then
|
||||
echo "date_to_load is empty"
|
||||
date_to_load=$(get_prev_business_day $(date -d "yesterday" '+%Y-%m-%d'))
|
||||
echo "Historical Data for ${date_to_load}"
|
||||
fi
|
||||
|
||||
echo "date_to_load=${date_to_load}"
|
||||
|
||||
Cmd="docker run"
|
||||
Cmd="${Cmd} --pull=always"
|
||||
Cmd="${Cmd} --network=host"
|
||||
Cmd="${Cmd} --name=${ContainerName}"
|
||||
Cmd="${Cmd} --rm"
|
||||
Cmd="${Cmd} --volume=${LogDir}:/logs"
|
||||
Cmd="${Cmd} ${DockerImage}"
|
||||
Cmd="${Cmd} -d ${date_to_load}"
|
||||
if [ -n "${NumSymbols}" ]; then
|
||||
Cmd="${Cmd} -N ${NumSymbols}"
|
||||
fi
|
||||
|
||||
echo $Cmd
|
||||
eval $Cmd
|
||||
|
||||
if [ "$?" != "0" ] ; then
|
||||
exit 1 # if killed we do not save last day
|
||||
fi
|
||||
@@ -82,11 +82,14 @@ if is_container_running "$ContainerName"; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [ -n "${date_to_load}" ]; then
|
||||
date_to_load=$(get_prev_business_day ${date_to_load})
|
||||
if [ -z "${date_to_load}" ]; then
|
||||
echo "date_to_load is empty"
|
||||
date_to_load=$(get_prev_business_day $(date -d "yesterday" '+%Y-%m-%d'))
|
||||
echo "Historical Data for ${date_to_load}"
|
||||
fi
|
||||
|
||||
echo "date_to_load=${date_to_load}"
|
||||
|
||||
Cmd="docker run"
|
||||
Cmd="${Cmd} --pull=always"
|
||||
Cmd="${Cmd} --network=host"
|
||||
@@ -103,10 +106,3 @@ eval $Cmd
|
||||
if [ "$?" != "0" ] ; then
|
||||
exit 1 # if killed we do not save last day
|
||||
fi
|
||||
|
||||
# # truncate to avoid false positive
|
||||
# date_to_load=$(echo "${date_to_load}" | xargs)
|
||||
# if [ -n "${date_to_load}" ]; then
|
||||
# echo "Saving date_to_load to ${LastDayFile}"
|
||||
# echo ${date_to_load} > ${LastDayFile}
|
||||
# fi
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.7.2,alpaca md QAT
|
||||
1.8.1,build for cvtt-rust uses cargo install
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# by chatGPT
|
||||
# ==========================================
|
||||
# homestore.cvtt.vpn SETTINGS
|
||||
# ==========================================
|
||||
|
||||
# Define source and destination base directories
|
||||
SOURCE_BASE_DIR="/works/cvtt/md_archive/equity/alpaca_md.OLD" # Replace with your actual source directory
|
||||
DESTINATION_BASE_DIR="/works/cvtt/md_archive/equity/alpaca_md" # Replace with your destination directory
|
||||
|
||||
# Loop through all .db.gz files in the source directory
|
||||
find "$SOURCE_BASE_DIR" -type f -name "*.db.gz" | while read -r file; do
|
||||
# Extract relevant directory components from the path
|
||||
relative_path="${file#$SOURCE_BASE_DIR/}"
|
||||
ticker=$(echo "$relative_path" | cut -d'/' -f2)
|
||||
year=$(echo "$relative_path" | cut -d'/' -f3)
|
||||
original_date=$(basename "$file" | cut -d'.' -f1)
|
||||
|
||||
# Define the new file name and destination path
|
||||
new_file_name="${original_date}.${ticker}.alpaca_1m_bars.db.gz"
|
||||
destination_dir="$DESTINATION_BASE_DIR/$year/A/$ticker"
|
||||
|
||||
# Create the destination directory if it doesn't exist
|
||||
mkdir -p "$destination_dir"
|
||||
#echo DEBUG mkdir -p "$destination_dir"
|
||||
|
||||
# Move and rename the file
|
||||
mv "$file" "$destination_dir/$new_file_name"
|
||||
#echo DEBUG mv "$file" "$destination_dir/$new_file_name"
|
||||
|
||||
echo "Moved $file to $destination_dir/$new_file_name"
|
||||
done
|
||||
@@ -167,10 +167,10 @@ EOF
|
||||
echo "Loading files"
|
||||
for stock in "${Stocks[@]}"; do
|
||||
StockLetter="${stock:0:1}"
|
||||
SourceFile=$(${date} -d ${md_date} "+%Y%m%d.${stock}.1min.db")
|
||||
SourceFile=$(${date} -d ${md_date} "+%Y%m%d.${stock}.alpaca_1m_bars.db")
|
||||
|
||||
SourceFileZip="${SourceFile}.gz"
|
||||
SourceFilePath=$(${date} -d ${md_date} "+${SourceRootDir}/${StockLetter}/${stock}/%Y/${SourceFileZip}")
|
||||
SourceFilePath=$(${date} -d ${md_date} "+${SourceRootDir}/%Y/${StockLetter}/${stock}/${SourceFileZip}")
|
||||
echo ${SourceFilePath}
|
||||
|
||||
download_file ${SourceFilePath}
|
||||
@@ -180,6 +180,3 @@ if [ -f ${TargetFilePath} ]; then
|
||||
chmod 600
|
||||
ls -lh ${TargetFilePath}
|
||||
fi
|
||||
|
||||
# mkdir -p /tmp/aaa
|
||||
# cp -r ${tmp_dir}/* /tmp/aaa/
|
||||
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "cryptovaltrading.com": {
|
||||
# "cloud18": {
|
||||
# "users": ["oleg"],
|
||||
# "type": "cloud",
|
||||
# "ssh_port": 7822,
|
||||
# # "to_check": "No"
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
|
||||
AlertChannel=Alerts-CVTT
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts
|
||||
|
||||
HOSTS_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
get_domains() {
|
||||
echo ${HOSTS_CONFIG} | jq -r '. | keys[]'
|
||||
}
|
||||
get_user_hosts() {
|
||||
local User=${1}
|
||||
local Domain=${2}
|
||||
|
||||
jdcmd="jq -r --arg domain \"$Domain\""
|
||||
jdcmd="$jdcmd --arg usr \"$User\""
|
||||
jdcmd="$jdcmd '.[\$domain]"
|
||||
jdcmd="$jdcmd | to_entries[]"
|
||||
jdcmd="$jdcmd | select(.value.users[]"
|
||||
jdcmd="$jdcmd | contains(\$usr))"
|
||||
jdcmd="$jdcmd | .key'"
|
||||
echo ${HOSTS_CONFIG} | eval ${jdcmd} |sed "s/$/.$Domain/" # >&2
|
||||
}
|
||||
|
||||
function host_alert() {
|
||||
alert=${1}
|
||||
if [ "${alert}" != "" ]
|
||||
then
|
||||
echo -e "### :fire: HOST ALERT \n${alert}" | ${Sender} ${AlertChannel}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_SSH_PORT=22
|
||||
Domains=("${Domains[@]}" "$(get_domains)")
|
||||
|
||||
for Domain in ${Domains[@]} ; do
|
||||
Hosts=("${Hosts[@]}" "$(get_user_hosts ${User} ${Domain})")
|
||||
done
|
||||
|
||||
for Host in ${Hosts[@]} ; do
|
||||
host=$(echo $Host | cut -d'.' -f1)
|
||||
Domain=$(echo $Host | cut -d'.' -f2-)
|
||||
|
||||
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
|
||||
if [ "${ToCheck^^}" == "NO" ]; then
|
||||
continue
|
||||
fi
|
||||
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
|
||||
|
||||
echo "Checking host: $Host on port $PortSSH"
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w5 "$Host" "$PortSSH"; then
|
||||
echo "Host $Host is not available on port $PortSSH"
|
||||
host_alert "Host $Host is not available on port $PortSSH"
|
||||
fi
|
||||
done
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "Jenkins" {
|
||||
# "to_check": "Yes",
|
||||
# "protocol": "http",
|
||||
# "host": "cvtt-build.cvtt.vpn",
|
||||
# "port": 8080
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
|
||||
AlertChannel=Alerts-CVTT
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_services
|
||||
|
||||
SERVICES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
echo $Sender
|
||||
echo $AlertChannel
|
||||
|
||||
|
||||
function service_alert() {
|
||||
alert="${1}"
|
||||
if [ "${alert}" != "" ]
|
||||
then
|
||||
#it may contain quotes
|
||||
alert=$(echo "${alert}" | sed 's/"/\\"/g')
|
||||
echo -e "### :boom: SERVICE ALERT\n${alert}" | ${Sender} ${AlertChannel}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
|
||||
mapfile -t SvcNames < <(echo ${SERVICES_CONFIG} | jq -r '. | keys[]')
|
||||
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
for SvcName in "${SvcNames[@]}" ; do
|
||||
ToCheck=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].to_check // "Yes"')
|
||||
if [ "${ToCheck^^}" == "NO" ]; then
|
||||
continue
|
||||
fi
|
||||
Host=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].host ')
|
||||
Port=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].port ')
|
||||
echo "Checking \"$SvcName\" (${Host}:${Port})"
|
||||
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w5 "$Host" "$Port"; then
|
||||
msg="Service \"${SvcName}\" (${Host}:${Port}) is not available"
|
||||
echo ${msg}
|
||||
service_alert "${msg}"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -69,7 +69,9 @@ function storage_check() {
|
||||
Cmd="ssh -p ${port} $host"
|
||||
Cmd="${Cmd} eval \"df -hTl"
|
||||
Cmd="${Cmd} -x squashfs"
|
||||
Cmd="${Cmd} | grep -v tmpfs"
|
||||
Cmd="${Cmd} -x tmpfs"
|
||||
Cmd="${Cmd} -x vfat"
|
||||
Cmd="${Cmd} -x devtmpfs"
|
||||
Cmd="${Cmd} | grep -v Filesystem\""
|
||||
|
||||
IFS=$'\n' ; lines=$(eval ${Cmd})
|
||||
|
||||
Reference in New Issue
Block a user