feature/variable-cron #1
58
.scalingTrash/backupshit
Normal file
58
.scalingTrash/backupshit
Normal file
@@ -0,0 +1,58 @@
|
||||
log_file = "/var/log/yankee-downloader.log"
|
||||
script_path = "/yankee-gnome-fire-consumer/consumer.py"
|
||||
|
||||
return "@@@"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import datetime
|
||||
import subprocess
|
||||
import socket
|
||||
import os
|
||||
|
||||
def getMinutes():
|
||||
|
||||
if current_time is None:
|
||||
current_time = datetime.datetime.now()
|
||||
|
||||
new_minute = (current_time.minute + 5) % 60 # The % operator performs the wrap-around
|
||||
new_hour = current_time.hour + (current_time.minute + 5) // 60 # Integer division for hour increment
|
||||
|
||||
# Create a new datetime object with the updated minute and handle hour rollover
|
||||
try:
|
||||
new_time = current_time.replace(minute=new_minute, hour=new_hour)
|
||||
except ValueError: # handles cases where the hour rollover causes day change
|
||||
new_time = current_time + datetime.timedelta(minutes=5)
|
||||
|
||||
return new_time
|
||||
|
||||
|
||||
|
||||
def generate_cron_entry():
|
||||
|
||||
"""Generates a cron entry that runs 5 minutes from now and logs server info."""
|
||||
|
||||
now = datetime.datetime.now()
|
||||
five_minutes_from_now = now + datetime.timedelta(minutes=5)
|
||||
|
||||
minute = five_minutes_from_now.minute
|
||||
hour = five_minutes_from_now.hour
|
||||
day = five_minutes_from_now.day
|
||||
month = five_minutes_from_now.month
|
||||
weekday = "*" # Weekday is left as * to run every day of the week. If you need specific weekdays, change this.
|
||||
|
||||
# Get server IP and hostname
|
||||
try:
|
||||
server_ip = socket.gethostbyname(socket.gethostname())
|
||||
server_hostname = socket.gethostname()
|
||||
except socket.gaierror:
|
||||
server_ip = "Unknown IP"
|
||||
server_hostname = "Unknown Hostname"
|
||||
|
||||
|
||||
log_file = "/var/log/yankee-downloader.log"
|
||||
script_path = "/yankee-gnome-fire-consumer/consumer.py"
|
||||
|
||||
print("getMinutes / ",getMinutes())
|
||||
218
.scalingTrash/compose.yaml
Normal file
218
.scalingTrash/compose.yaml
Normal file
@@ -0,0 +1,218 @@
|
||||
services:
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################001
|
||||
|
||||
yankee-desktop-remix-001:
|
||||
container_name: yankee-desktop-remix-001
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-001
|
||||
ports:
|
||||
- "20012:22"
|
||||
- "20018:80"
|
||||
- "20019:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################002
|
||||
|
||||
yankee-desktop-remix-002:
|
||||
container_name: yankee-desktop-remix-002
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-002
|
||||
ports:
|
||||
- "20022:22"
|
||||
- "20028:80"
|
||||
- "20029:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################003
|
||||
|
||||
yankee-desktop-remix-003:
|
||||
container_name: yankee-desktop-remix-003
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-003
|
||||
ports:
|
||||
- "20032:22"
|
||||
- "20038:80"
|
||||
- "20039:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################004
|
||||
|
||||
yankee-desktop-remix-004:
|
||||
container_name: yankee-desktop-remix-004
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-004
|
||||
ports:
|
||||
- "20042:22"
|
||||
- "20048:80"
|
||||
- "20049:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################005
|
||||
|
||||
yankee-desktop-remix-005:
|
||||
container_name: yankee-desktop-remix-005
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-005
|
||||
ports:
|
||||
- "20052:22"
|
||||
- "20058:80"
|
||||
- "20059:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################006
|
||||
|
||||
yankee-desktop-remix-006:
|
||||
container_name: yankee-desktop-remix-006
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-006
|
||||
ports:
|
||||
- "20062:22"
|
||||
- "20068:80"
|
||||
- "20069:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################007
|
||||
|
||||
yankee-desktop-remix-007:
|
||||
container_name: yankee-desktop-remix-007
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-007
|
||||
ports:
|
||||
- "20072:22"
|
||||
- "20078:80"
|
||||
- "20079:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
##########################################
|
||||
##
|
||||
## volumes / yankee-desktop-remix
|
||||
##
|
||||
##########################################
|
||||
|
||||
volumes:
|
||||
yankee-nfs-downloads:
|
||||
driver_opts:
|
||||
type: "nfs"
|
||||
o: nfsvers=4,addr=osiris.yankee.embanet.online,nolock,hard,rw
|
||||
device: ":/"
|
||||
|
||||
38
.scalingTrash/cronExtras2.bash
Normal file
38
.scalingTrash/cronExtras2.bash
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
function recycle{
|
||||
start_hour=$(date +%H)
|
||||
|
||||
if (( current_minute + 5 >= 60 )); then
|
||||
|
||||
start_hour=$(( (start_hour + 1) % 24 )) # handle wrap-around at 24 hours
|
||||
|
||||
fi
|
||||
|
||||
start_day=$(date +%d)
|
||||
start_month=$(date +%m)
|
||||
start_weekday=$(date +%w)
|
||||
|
||||
|
||||
# Get external IP and hostname (using a reliable method)
|
||||
|
||||
external_ip=$(curl -s ifconfig.me) # Or use dig +short myip.opendns.com
|
||||
|
||||
hostname=$(hostname -f)
|
||||
|
||||
|
||||
# Construct the cron command with the calculated time and logging
|
||||
cron_command="$start_minute $start_hour $start_day $start_month $start_weekday python3 /yankee-gnome-fire-consumer/consumer.py >> /var/log/yankee-downloader.log 2>&1"
|
||||
|
||||
# Add IP and hostname to log message *before* the python script runs
|
||||
log_message="Starting consumer at $(date) from $hostname ($external_ip): "
|
||||
|
||||
# Add the log message to the log file, then run the python script and redirect stderr
|
||||
# This is done using a subshell to ensure the log message comes before the python script's output.
|
||||
cron_command_with_log="echo \"$log_message\" >> /var/log/yankee-downloader.log 2>&1; $cron_command"
|
||||
|
||||
|
||||
# Add the cron job (using crontab -l to get existing entries, adding the new one, and then setting the crontab)
|
||||
(crontab -l; echo "$cron_command_with_log") | crontab -
|
||||
|
||||
|
||||
echo "Cron job added: $cron_command_with_log"
|
||||
23
Dockerfile
23
Dockerfile
@@ -32,26 +32,3 @@ RUN bash installs/cron.bash
|
||||
COPY provision/startup/startup.sh /startup.sh
|
||||
|
||||
##
|
||||
|
||||
|
||||
####
|
||||
|
||||
COPY ping.script /tmp/ping.bash
|
||||
|
||||
RUN chmod +x /tmp/ping.bash
|
||||
|
||||
COPY ping2.script /tmp/ping2.bash
|
||||
|
||||
RUN chmod +x /tmp/ping2.bash
|
||||
|
||||
RUN ls -lha /tmp/
|
||||
|
||||
####
|
||||
|
||||
COPY cronfile /etc/cron.d/cronfile
|
||||
|
||||
# Give execution rights on the cron job
|
||||
RUN chmod 0644 /etc/cron.d/cronfile
|
||||
|
||||
# Apply the cron job
|
||||
RUN crontab -u root /etc/cron.d/cronfile
|
||||
|
||||
0
compose.template
Executable file → Normal file
0
compose.template
Executable file → Normal file
145
compose.yaml
145
compose.yaml
@@ -58,151 +58,6 @@ services:
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################003
|
||||
|
||||
yankee-desktop-remix-003:
|
||||
container_name: yankee-desktop-remix-003
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-003
|
||||
ports:
|
||||
- "20032:22"
|
||||
- "20038:80"
|
||||
- "20039:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################004
|
||||
|
||||
yankee-desktop-remix-004:
|
||||
container_name: yankee-desktop-remix-004
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-004
|
||||
ports:
|
||||
- "20042:22"
|
||||
- "20048:80"
|
||||
- "20049:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################005
|
||||
|
||||
yankee-desktop-remix-005:
|
||||
container_name: yankee-desktop-remix-005
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-005
|
||||
ports:
|
||||
- "20052:22"
|
||||
- "20058:80"
|
||||
- "20059:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################006
|
||||
|
||||
yankee-desktop-remix-006:
|
||||
container_name: yankee-desktop-remix-006
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-006
|
||||
ports:
|
||||
- "20062:22"
|
||||
- "20068:80"
|
||||
- "20069:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################007
|
||||
|
||||
yankee-desktop-remix-007:
|
||||
container_name: yankee-desktop-remix-007
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-007
|
||||
ports:
|
||||
- "20072:22"
|
||||
- "20078:80"
|
||||
- "20079:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
##########################################
|
||||
##
|
||||
## volumes / yankee-desktop-remix
|
||||
|
||||
109
compose1x.bash
Executable file
109
compose1x.bash
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
|
||||
set -e
|
||||
|
||||
set -x
|
||||
|
||||
##
|
||||
|
||||
reset
|
||||
|
||||
clear
|
||||
|
||||
##
|
||||
|
||||
|
||||
##
|
||||
|
||||
processorCount=`grep -c '^processor' /proc/cpuinfo`
|
||||
|
||||
processorCount=1
|
||||
|
||||
echo "num cpus / "$processorCount
|
||||
|
||||
for i in $(seq 2 "$processorCount"); do
|
||||
|
||||
echo "Processing unit: $i"
|
||||
|
||||
##
|
||||
|
||||
rm -f compose.yaml
|
||||
|
||||
echo "services:" >> compose.yaml
|
||||
|
||||
##
|
||||
|
||||
for x in $(seq 1 "$processorCount"); do
|
||||
|
||||
i=$(printf "%03d" "$x")
|
||||
|
||||
# Create the service definition
|
||||
service_def=$(cat <<EOF
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################$i
|
||||
|
||||
yankee-desktop-remix-$i:
|
||||
container_name: yankee-desktop-remix-$i
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-$i
|
||||
ports:
|
||||
- "2${i}2:22"
|
||||
- "2${i}8:80"
|
||||
- "2${i}9:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
# Append the service definition to compose.yaml
|
||||
echo "$service_def" >> compose.yaml
|
||||
|
||||
done
|
||||
|
||||
|
||||
# Add the volumes section ONCE after the loop (outside)
|
||||
cat <<EOF >> compose.yaml
|
||||
|
||||
##########################################
|
||||
##
|
||||
## volumes / yankee-desktop-remix
|
||||
##
|
||||
##########################################
|
||||
|
||||
volumes:
|
||||
yankee-nfs-downloads:
|
||||
driver_opts:
|
||||
type: "nfs"
|
||||
o: nfsvers=4,addr=osiris.yankee.embanet.online,nolock,hard,rw
|
||||
device: ":/"
|
||||
|
||||
EOF
|
||||
#... your commands to process each unit...
|
||||
|
||||
done
|
||||
##
|
||||
|
||||
docker compose down --remove-orphans
|
||||
|
||||
docker compose up -d
|
||||
|
||||
docker stats
|
||||
1
cronfile
1
cronfile
@@ -1,5 +1,6 @@
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
* * * * * python3 /yankee-gnome-fire-consumer/consumer.py >> /var/log/yankee-downloader.log 2>&1
|
||||
|
||||
* * * * * /tmp/ping2.bash >> /var/log/cron.log 2>&1
|
||||
|
||||
8
crontabX
Normal file
8
crontabX
Normal file
@@ -0,0 +1,8 @@
|
||||
SHELL=/bin/bash
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
57 11 * * * python3 /yankee-gnome-fire-consumer/consumer.py >> /tmp/root/Downloads/.logs/yankee-node-96.255.165.82-veneno.log 2>&1
|
||||
|
||||
* * * * * /tmp/ping2.bash >> /var/log/cron.log 2>&1
|
||||
|
||||
@@ -113,6 +113,13 @@ chmod +x *.sh
|
||||
|
||||
####
|
||||
|
||||
echo "scheduling the cron job"
|
||||
|
||||
bash smart-cron-builder.bash
|
||||
|
||||
echo "cron job scheduled"
|
||||
|
||||
####
|
||||
|
||||
exec /bin/tini -- supervisord -n -c /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user