Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ fi

# Configure redis
cd ~/suricate
sudo mkdir -p /var/lib/redis
sudo chown redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis
sudo cp templates/redis.conf /etc/redis.conf

# Create the systemd service file for Redis
Expand Down
10 changes: 6 additions & 4 deletions scripts/start_suricate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

export HOME=/discos-sw/discos/
export PATH="/alma/ACS-2021DEC/pyenv/shims:/alma/ACS-2021DEC/pyenv/bin:$PATH"
export PYENV_ROOT="/alma/ACS-2021DEC/pyenv"
export PATH="$PYENV_ROOT/shims:/alma/ACS-2021DEC/pyenv/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:/usr/lib64"
/usr/local/bin/redis-cli CONFIG SET stop-writes-on-bgsave-error no
source /discos-sw/discos/.bashrc
source "$HOME/.bashrc"

exec /alma/ACS-2021DEC/pyenv/shims/suricate-server start
"$PYENV_ROOT/shims/suricate-server" start & PID1=$!
"$PYENV_ROOT/shims/rqworker" -P "$HOME/suricate/suricate discos-api" & PID2=$!

wait $PID1 $PID2
8 changes: 4 additions & 4 deletions scripts/stop_suricate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

export HOME=/discos-sw/discos/
export PATH="/alma/ACS-2021DEC/pyenv/shims:/alma/ACS-2021DEC/pyenv/bin:$PATH"
export PYENV_ROOT="/alma/ACS-2021DEC/pyenv"
export PATH="$PYENV_ROOT/shims:/alma/ACS-2021DEC/pyenv/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:/usr/lib64"
/usr/local/bin/redis-cli CONFIG SET stop-writes-on-bgsave-error no
source /discos-sw/discos/.bashrc
source "$HOME/.bashrc"

exec /alma/ACS-2021DEC/pyenv/shims/suricate-server stop
"$PYENV_ROOT/shims/suricate-server" stop
pkill -f rqworker
2 changes: 1 addition & 1 deletion scripts/suricate-server
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ elif args.action == 'stop' and args.no_components:
print('ERROR: can not execute stop with no_components')
sys.exit(1)
else:
url = f'{BASEURL}:{PORT}/publisher/api/v0.1/stop'
url = f'http://{BASEURL}:{PORT}/publisher/api/v0.1/stop'
msg = ''
try:
requests.post(url, timeout=2)
Expand Down
21 changes: 4 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import os
from shutil import copyfile
from setuptools import setup, find_packages
Expand Down Expand Up @@ -27,12 +25,14 @@
except OSError:
pass # Directory already exists


for file_name in os.listdir('templates'):
source_file = os.path.join('templates', file_name)
dest_file = os.path.join(template_dir, file_name)
copyfile(source_file, dest_file)

# Read requirements.txt
with open('requirements.txt', encoding='utf-8') as f:
requirements = f.read().splitlines()

setup(
name='suricate',
Expand All @@ -47,20 +47,7 @@
keywords='Alma Common Software property publisher',
scripts=['scripts/suricate-server', 'scripts/suricate-config'],
platforms='all',
install_requires=[
'redis',
'apscheduler',
'MarkupSafe',
'Jinja2',
'Flask',
'itsdangerous',
'Flask-SQLAlchemy',
'Flask-Migrate',
'pyyaml',
'rq==1.16.2',
'python-dotenv',
'requests',
],
install_requires=requirements,
classifiers=[
'Intended Audience :: Alma Common Software users',
'Operating System :: OS Independent',
Expand Down
5 changes: 4 additions & 1 deletion startup/suricate.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/start_suricate.sh
ExecStop=/usr/local/bin/start_suricate.sh
ExecStop=/usr/local/bin/stop_suricate.sh
TimeoutStartSec=5
TimeoutStopSec=5
Restart=on-failure
User=discos
PIDFile=/var/run/suricate-server

Expand Down
30 changes: 28 additions & 2 deletions suricate/monitor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import json
import redis
from pytz import utc
from apscheduler import events
from apscheduler.executors.pool import ProcessPoolExecutor, ThreadPoolExecutor

from suricate.monitor.schedulers import Scheduler
from suricate.configuration import config, dt_format
Expand All @@ -21,7 +23,17 @@

class Publisher:

s = Scheduler()
s = Scheduler(
executors={
'default': ThreadPoolExecutor(10),
'processpool': ProcessPoolExecutor(100),
},
job_defaults={
'coalesce': False,
'max_instances': 1,
},
timezone=utc,
)

def __init__(self, *args):
self.unavailable_components = {}
Expand All @@ -41,8 +53,12 @@ def __init__(self, *args):
func=self.rescheduler,
args=(),
id='rescheduler',
replace_existing=True,
coalesce=True,
max_instances=1,
trigger='interval',
seconds=config['SCHEDULER']['reschedule_interval']

)

def add_jobs(self, _config):
Expand Down Expand Up @@ -307,7 +323,17 @@ def shutdown(cls):
cls.s.remove_all_jobs()
cls.s.shutdown(wait=False)
time.sleep(0.2)
cls.s = Scheduler()
cls.s = Scheduler(
executors={
'default': ThreadPoolExecutor(10),
'processpool': ProcessPoolExecutor(100),
},
job_defaults={
'coalesce': False,
'max_instances': 1,
},
timezone=utc,
)

def _set_attr_error(
self,
Expand Down
1 change: 1 addition & 0 deletions suricate/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def start_webserver():
except socket.error as ex:
logger.error(ex)
sys.exit(1)
logger.info('webserver started')


def start(components=None):
Expand Down
2 changes: 1 addition & 1 deletion templates/redis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ rdb-del-sync-files no
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./
dir /var/lib/redis

################################# REPLICATION #################################

Expand Down
16 changes: 14 additions & 2 deletions templates/srt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ COMPONENTS:
units: none
description: "MNG_OK or MNG_WARNING or MNG_FAILURE"

ANTENNA/Mount:
startup_delay: 10
container: AntennaContainer
properties:
- name: azimuth
timer: 2.0
units: degree
description: "azimuth (encoder value), without any correction"
- name: elevation
timer: 2.0
units: degree
description: "elevation (encoder value), without any correction"

RECEIVERS/SRT7GHzReceiver:
startup_delay: 10
Expand Down Expand Up @@ -131,8 +143,8 @@ COMPONENTS:
description: "wind peak catched on the last 5 seconds"

HTTP:
# Base URL and port of the API
baseurl: http://127.0.0.1
# Base URL (without http://) and port of the API
baseurl: 0.0.0.0
port: 5000

SCHEDULER:
Expand Down
Loading