I have recently installed the .Net core framework 2.2 from Microsoft's website on my Ubuntu server.
Whenever you run the dotnet [.dll file]
it will have a prompt saying:
Application running on port 3030
Press Ctrl+C to close server
I was wondering how would I be able to run more than one .Net Core application. It seems I can SSH the server again and load up another application. That will load both applications at once.
Is there a way where I can bypass the keyboard lock when it only lets me to press Ctrl+C?
You can suspend the application with Ctl+z. Once suspended, resume the application in the background with the bg
command, or you can bring it back to the foreground again with the fg
command. If you background the application and run more applications afterwards, you can find the job number of your application with the jobs
command after which you can use fg <job number>
to bring it to the foreground before stopping it with Ctl+c.
A better approach is to create a Systemd unit file which allows you to stop and start the service at your leisure or on boot. Run sudo systemctl edit --force myFirstDotNetService.service
. In the editor, add the following:
[Unit]
Description= My First Dot Net Service
[Service]
ExecStart = /path/to/dotnet /path/to/dll-file
[Install]
WantedBy=multi-user.target
There are many more options you can add to this file, but the above should get you started.
Next, let the server know about this new file with: sudo systemctl daemon-reload
.
You can now start the service with: sudo systemctl start myFirstDotNetService
and stop it with sudo systemctl stop myFirstDotNetService
. When you start, the application is placed in the background and the command prompt returns.
You can make it automatically start at boot with: sudo systemctl enable myFirstDotNetService
and stop this with sudo systemctl disable myFirstDotNetService
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments