Voor linux gebruik het commando
uptime
voor mysql:
gebruikt:
SELECT DATE_SUB(now(), INTERVAL variable_value SECOND) "LAST STARTUP" from performance_schema.global_status where variable_name='Uptime';
of in linux:
service mysql status
blog van Patrick Vos
Voor linux gebruik het commando
uptime
voor mysql:
gebruikt:
SELECT DATE_SUB(now(), INTERVAL variable_value SECOND) "LAST STARTUP" from performance_schema.global_status where variable_name='Uptime';
of in linux:
service mysql status
in asp.net
add systemd support
add forwarding for nginx
on ubuntu create a directory in:
/var/www/<appname>
build / publish asp.net project for linux
dotnet publish -c Release -r linux-x64 --no-self-contained
Check if .net runtime is installed if it does not work you can also use --self-contained in your build command
copy contents to directory
give permission to <appname> dir with command:
chmod 775 -R /var/www/<appname>
set execute rechten op exe file
chmod +x /var/www/<appname dir>/<appname> (without dll) in linux
Create a service file in systemd
create an empty <appname>.service file (touch filename)
put in the following content (nano filename)
[Unit]
Description=app description
After=network.target
[Service]
WorkingDirectory=/var/www/uitgekookt-logistics-route-generation-api/current
ExecStart=/var/www/<appdir>/<linux generated file without extension / appname>
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
Environment=AllowedHosts=*
Environment=ApplicationInsights__InstrumentationKey=
Environment=Connectionstrings__ABC=abc
Environment=ASPNETCORE_URLS=http://localhost:5040
Enable service:
sudo systemctl enable <appname>.service
Start
sudo systemctl start <appname>.service
For nginx create an <appname> file in /etc/nginx/sites-available/ dir
with contents:
server {
listen 50400; //external port
listen [::]:50400;
location / {
proxy_pass http://127.0.0.1:5040; //portnumber of .net api
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
create a systemlink from sites-available to sites-enabled:
ln -s /etc/nginx/sites-available/<appname> /etc/nginx/sites-enabled/<appname>
allow port 50400 in firewall (ufw enable)
reload nginx (nginx -s reload)
when there are issues with the application scan the log via:
sudo journalctl -fu <appname>.service
Meer info:
Host ASP.NET Core on Linux with Nginx | Microsoft Docs
How To Install MySQL on Ubuntu 20.04 | DigitalOcean
check if mysql is running systemctl list-units --type=service --state=running or
systemctl --type=service
grant acces to user
open port in firewall for external communication
Run SQL file in MySQL database from terminal? (tutorialspoint.com)
install python 3.9
install pip for use in commandline:
download :get-pip.py
see: https://www.geeksforgeeks.org/how-to-install-pip-in-macos
install wagtail; see https://wagtail.org/developers/
when modulenotfound exception use:
python -m pip install djangopython -m pip install wagtail
place a staticwebapp.config.json file in the root of your application.
Configure Azure Static Web Apps | Microsoft Docs
fe:
Build a windows service on windows server you need to compile the assemblies with win-x64 runtime
dotnet build -c Release --runtime win-x64 --no-self-contained
dotnet publish-c Release --runtime win-x64 --no-self-contained
use sc.exe util to install the windows service
sc.exe create "ServiceName" binpath="Dir\Service.exe"
info: