MDriven on Synology

How to run MDriven on a Synology box

This guide will help you get up and running with MDriven Server and MDriven Turnkey environment on a Synology DSM. Since the synology has the ability to run MariaDB with an easy install from the built-in package center, we will assume this would be the best solution. There is also an option to run the database in Docker - then we can choose for ex PostgreSQL.

Preparations

Download the latest MDriven Core Server and Turnkey binaries for Linux from mdriven.net and ASP.NET Core Runtime x64 for Linux

Create a new share on the synology box ex [\\synology\webapp ] where we will run the MDriven application from.

If Maria DB is not installed, add it from Package center, or add your flavor of database as an Docker image.

Install ASP.NET Core Runtime

Connect to your synology through SSH. This assumes you have enabled SSH on you synology box.

You will now install asp.net by extracting the tar.gz-file and adding a path to environment variable.

mkdir -p /usr/local/bin/dotnet && tar zxf aspnetcore-runtime-8.0.3-linux-x64.tar.gz -C /usr/local/bin/dotnet
export DOTNET_ROOT=/usr/local/bin/dotnet
export PATH=$PATH:/usr/local/bin/dotnet

Initiate a database

For mySQL: Create database MyApp and user myAppUser in mySQL

mysql -p -u root

CREATE DATABASE myApp;
CREATE USER myAppUser@localhost IDENTIFIED BY 'myPassword'; GRANT ALL PRIVILEGES ON myApp.* TO myAppUser@localhost;

Setup MDriven

Extract Mdriven Turnkey Core for Linux into \\synology\webapp\myApp\MDTurnkey

Extract Mdriven Server Core for Linux into \\synology\webapp\myApp\MDServer

Create a scriptfile run.sh* that will be used to start the MDriven environment.

Save it together with your application on \\synology\webapp\myApp\

dotnet /volume1/webapp/myApp/MDServer/AppCompleteGenericCore.dll -port=5010 -nohttps
dotnet /volume1/webapp/myApp/MDTurnkey/StreaminAppCoreWebApp.dll -port=5011 -nohttps

If you're using Notepad++, be sure to end line in unix (LF), Edit -> EOL Conversion->UnixConfiguration

Create a Triggered Task that will run at boot time in your Synology box by navigating to Controll Panel -> Task Scheduler

Run your script as follows: /bin/bash /volume1/webapp/myApp/run.sh

Configure MDriven Server

Now you are ready to browse to your MDriven Server on https://synology:5010 and set up your MySQL database with connection string.

Server=localhost;Port=3306;Database=myApp;Uid=myAppUser;Pwd=myPassword;

As always, we have to configure MdrivenServerOverride.xml and TurnkeySettingsOverride.xml to make sure we have a smooth process of upgrading the servers.

MySQL/MariaDB: Unfortunately, there may be a bug between some versions of the MySQL connector and MySQL server which may result in an error when uploading your model.

*Extended run.sh that will restart the application if it is currently running:

#!/bin/bash /volume1/webapp/myApp/run.sh
clear
BLUE='\033[0;34m'
printf "${BLUE}STARTING MDRIVEN ENVIRONMENT\n\n"
APPNAME=myApp
TURNKEYPORT=5011
SERVERPORT=5010

# Kill process to restart webapplications
netstat -lpn | grep ":$TURNKEYPORT" | awk '{sub(/\/.*/, "", $NF); print $NF}' | xargs -i kill -kill {}
netstat -lpn | grep ":$SERVERPORT" | awk '{sub(/\/.*/, "", $NF); print $NF}' | xargs -i kill -kill {}

# Start MDriven Environment
sleep 1s
cd /volume1/webapp/myApp/MDServer
/usr/local/bin/dotnet/dotnet /volume1/webapp/myApp/MDServer/AppCompleteGenericCore.dll -port=$SERVERPORT -nohttps &
sleep 15s
cd /volume1/webapp/myApp/MDTurnkey
/usr/local/bin/dotnet/dotnet /volume1/webapp/myApp/MDTurnkey/StreaminAppCoreWebApp.dll -port=$TURNKEYPORT -nohttps &
printf "${BLUE}RUNNING IN BACKGROUND\n\n"
This page was edited 157 days ago on 06/17/2024. What links here