2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 25169
/ 2 Years ago, wed, march 2, 2022, 3:47:10
I'm new to systemd and would like to know what is the best strategy for restarting my web application whenever I deploy new version.
Currently I start my service on boot and it just sits there, however I would like it to restart automatically whenever I change the files since whenever I push to master on gitlab the runner gets the files, compiles and copies it to correct directory. Then I want to restart it or close it however I don't know how since to restart it requires sudo.
Here is my service file
[Unit]
After=mongod.service
[Service]
WorkingDirectory=/var/app/mywebsite/Web
Environment="HOME=/home/stan"
Environment="DOTNET_CLI_TELEMETRY_OPTOUT=1"
Environment="DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1"
ExecStart=/usr/bin/dotnet run -c Release -p /var/app/mywebsite/Web/project.json
[Install]
WantedBy=multi-user.target
Here is my ci file to be more specific
before_script:
- set DOTNET_CLI_TELEMETRY_OPTOUT=1
- set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
- set HOME=/home/stan
- cd Web
- dotnet restore
- dotnet build -c Release
- cd ..
copy:
script:
- cp -R ./* /var/app/mywebsite/ # After this I would like to restart the website service
More From » systemd