C
C#3mo ago
Saiyanslayer

How to Setup a remote Blazor server on Ubuntu

Hey all, I'm working on a project and I'm getting overwhelmed with the options and need some guidance. I'm developing a Blazor project on my windows pc and trying to host it on an Ubuntu pc/server. It sometimes works, but I can't seem to get it to run as a service on the server. To help troubleshoot, I want to remotely attach to the process, but it's not being detected. Right now, I'm publishing to folder (debug as opposed to release) and uploading the files to /var/project. I'd like to attach to the process at the very start, but I can't find how. Ideally, I'd like to be able to start debugging on my windows pc, but run on the Linux to see why it's failing. Failing that, what would be a good setup for this? Should I explore docker instead?
4 Replies
jcotton42
jcotton423mo ago
How are you running it as a service? systemd unit? @Saiyanslayer
Saiyanslayer
SaiyanslayerOP3mo ago
Systemctl
jcotton42
jcotton423mo ago
So systemd. Show the unit file you wrote.
Saiyanslayer
SaiyanslayerOP3mo ago
Description=BlazorPatients running on Ubuntu

[Service]
WorkingDirectory=/var/patienttracker
ExecStart=dotnet /var/patienttracker/BlazorPatients.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=60
KillSignal=SIGINT
SyslogIdentifier=patienttracker
User=nsmela
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
Description=BlazorPatients running on Ubuntu

[Service]
WorkingDirectory=/var/patienttracker
ExecStart=dotnet /var/patienttracker/BlazorPatients.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=60
KillSignal=SIGINT
SyslogIdentifier=patienttracker
User=nsmela
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
I've changed it now to match a tutorial i was following:
Description=BlazorPatients running on Ubuntu

[Service]
WorkingDirectory=/var/www/patienttracker
ExecStart=dotnet /var/www/patienttracker/BlazorPatients.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=60
KillSignal=SIGINT
SyslogIdentifier=patienttracker
User=nsmela
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
Description=BlazorPatients running on Ubuntu

[Service]
WorkingDirectory=/var/www/patienttracker
ExecStart=dotnet /var/www/patienttracker/BlazorPatients.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=60
KillSignal=SIGINT
SyslogIdentifier=patienttracker
User=nsmela
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
I reloaded the service and restart the service, get this response:
● kestrel-patienttracker.service - BlazorPatients running on Ubuntu
Loaded: loaded (/etc/systemd/system/kestrel-patienttracker.service; enabled; preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2024-09-11 08:15:35 PDT; 12s ago
Process: 10652 ExecStart=dotnet /var/www/patienttracker/BlazorPatients.dll (code=exited, status=203/EXEC)
Main PID: 10652 (code=exited, status=203/EXEC)
CPU: 1ms
● kestrel-patienttracker.service - BlazorPatients running on Ubuntu
Loaded: loaded (/etc/systemd/system/kestrel-patienttracker.service; enabled; preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2024-09-11 08:15:35 PDT; 12s ago
Process: 10652 ExecStart=dotnet /var/www/patienttracker/BlazorPatients.dll (code=exited, status=203/EXEC)
Main PID: 10652 (code=exited, status=203/EXEC)
CPU: 1ms
but if i go to /var/www/patienttracker/ and use:
dotnet BlazorPatients.dll
dotnet BlazorPatients.dll
it runs and if i use VS2022 and try to "Attach to Process", I can't see the process on the list there is a "BlazorPatients.pdb" file in the folder and the publish configuration is Debug
Want results from more Discord servers?
Add your server