diff --git a/scripts/start-hyperopt-worker.py b/scripts/start-hyperopt-worker.py new file mode 100755 index 000000000..8b0ae6326 --- /dev/null +++ b/scripts/start-hyperopt-worker.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import multiprocessing +import os +import subprocess + +PROC_COUNT = multiprocessing.cpu_count() - 1 +DB_NAME = 'freqtrade_hyperopt' +WORK_DIR = os.path.join( + os.path.sep, + os.path.abspath(os.path.dirname(__file__)), + '..', '.hyperopt', 'worker' +) +if not os.path.exists(WORK_DIR): + os.makedirs(WORK_DIR) + +# Spawn workers +command = [ + 'hyperopt-mongo-worker', + '--mongo=127.0.0.1:1234/{}'.format(DB_NAME), + '--poll-interval=0.1', + '--workdir={}'.format(WORK_DIR), +] +processes = [subprocess.Popen(command) for i in range(PROC_COUNT)] + +# Join all workers +for proc in processes: + proc.wait() diff --git a/scripts/start-hyperopt-worker.sh b/scripts/start-hyperopt-worker.sh deleted file mode 100755 index 1b0d240ca..000000000 --- a/scripts/start-hyperopt-worker.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -DB_NAME=freqtrade_hyperopt - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -WORK_DIR="${DIR}/../.hyperopt/worker" - -mkdir -p "${WORK_DIR}" -hyperopt-mongo-worker \ - --mongo="127.0.0.1:1234/${DB_NAME}" \ - --poll-interval=0.1 \ - --workdir="${WORK_DIR}" \ No newline at end of file diff --git a/scripts/start-mongodb.py b/scripts/start-mongodb.py new file mode 100755 index 000000000..910ee9233 --- /dev/null +++ b/scripts/start-mongodb.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import os +import subprocess + + +DB_PATH = os.path.join( + os.path.sep, + os.path.abspath(os.path.dirname(__file__)), + '..', '.hyperopt', 'mongodb' +) +if not os.path.exists(DB_PATH): + os.makedirs(DB_PATH) + +subprocess.Popen([ + 'mongod', + '--bind_ip=127.0.0.1', + '--port=1234', + '--nohttpinterface', + '--dbpath={}'.format(DB_PATH), +]).wait() diff --git a/scripts/start-mongodb.sh b/scripts/start-mongodb.sh deleted file mode 100755 index 02b6624f4..000000000 --- a/scripts/start-mongodb.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -DB_PATH="${DIR}/../.hyperopt/mongodb" - -mkdir -p "${DB_PATH}" -mongod --dbpath "${DB_PATH}" \ - --bind_ip 127.0.0.1 \ - --port 1234 \ - --directoryperdb \ - --journal \ - --nohttpinterface