64 lines
1.7 KiB
Nix
64 lines
1.7 KiB
Nix
{ mariadb-client
|
|
, python3
|
|
, nodejs
|
|
, writeShellApplication
|
|
, frappe-app
|
|
, erpnext-app
|
|
, frappe-erpnext-assets
|
|
, erpnext-nginx-conf
|
|
}:
|
|
let
|
|
penv = python3.buildEnv.override {
|
|
extraLibs = [
|
|
python3.pkgs.frappe
|
|
python3.pkgs.erpnext
|
|
python3.pkgs.bench
|
|
];
|
|
};
|
|
in writeShellApplication {
|
|
name = "run-erpnext";
|
|
runtimeInputs = [mariadb-client nodejs penv];
|
|
text = ''
|
|
export PYTHON_PATH=${penv}/${python3.sitePackages}
|
|
|
|
tmp=/tmp/erpnext
|
|
|
|
mkdir -p $tmp/apps $tmp/sites $tmp/config/pids $tmp/logs/nginx $tmp/env/bin
|
|
|
|
ln -s ${frappe-app}/share/apps/frappe $tmp/apps/frappe
|
|
ln -s ${erpnext-app}/share/apps/erpnext $tmp/apps/erpnext
|
|
ln -s ${frappe-erpnext-assets}/share/sites/assets $tmp/sites/assets
|
|
ln -s ${penv} $tmp/env
|
|
ln -s ${erpnext-nginx-conf} $tmp/nginx-erpnext.conf
|
|
|
|
cat > $tmp/sites/apps.txt <<EOF
|
|
frappe
|
|
erpnext
|
|
EOF
|
|
|
|
cat >$tmp/sites/common_site_config.json <<EOF
|
|
{
|
|
"db_host": "localhost",
|
|
"db_port": 3306,
|
|
"db_name": "erpnext" ,
|
|
"db_password": "erpnext" ,
|
|
"redis_cache": "redis://localhost:6379?db=0",
|
|
"redis_queue": "redis://localhost:6379?db=1",
|
|
"redis_socketio": "redis://localhost:6379?db=2",
|
|
"socketio_port": 3000
|
|
}
|
|
EOF
|
|
|
|
# Upstream initializes the DB with this command
|
|
# TODO: Make this idempotent
|
|
cd $tmp
|
|
bench new-site localhost --mariadb-root-password password --admin-password admin
|
|
bench --site localhost install-app erpnext
|
|
|
|
echo "Workdir: $tmp"
|
|
# TODO: Run these as systemd units
|
|
node $tmp/apps/frappe/socketio.js &
|
|
gunicorn --chdir="$tmp/sites" --bind=0.0.0.0:9090 --threads=4 --workers=2 --worker-class=gthread --worker-tmp-dir=/dev/shm --timeout=120 --preload frappe.app:application
|
|
'';
|
|
}
|