acep-uaf / camio-meter-streams

0 stars 0 forks source link

Code structure brainstorm #56

Open teknofire opened 4 months ago

teknofire commented 4 months ago

code deployment

/var/opt/acep-camio/GITHUB_REPO_NAME

How to start the data pipeline download

./data-pipeline --config /etc/acep-kea-events/config.yaml --output ~/data/
`--output` would override the output directory in the config

pseudocode - data-pipeline

configs = parse args['config']
credentials = configs['credentials']
config['meters'].each do |meter|
  ENV['username'] = meter['username'] || credentials['username']
  ENV['password'] = meter['password'] || credentials['password']

  exec "meters/#{meter['type']}/download.sh #{meter['ip']} #{output_dir}/#{date}/#{meter_id}"
end

meters/sel735/download.sh

# do something to parse cli flags
meter_ip = $1
output_dir = $2

# connect to the meter
exec ./connect.sh

###
# Call a script to get the new event ids
#  $('./get_events.sh $meter_ip'); should printout a list of event ids seperated by new lines
# example:
# 1234
# 1235
# 1236
# for file in $(ls -l); do echo $file; done
###

for event_id in $(./get_events.sh $meter_ip); do 
  exec ./download_event.sh $meter_ip $event_id $output_dir/$event_id
done

Rambling on how paths/current working directories for scripts

#!/usr/bin/env bash

echo "The script you are running has:"
echo "basename: [$(basename "$0")]"
echo "dirname : [$(dirname "$0")]"
echo "pwd     : [$(pwd)]"

cwd=$(dirname "${0}")

exec $cwd/test.sh