-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4. BuildAndInstallService.txt
62 lines (50 loc) · 1.71 KB
/
4. BuildAndInstallService.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# locally
rm ProgNet.Service.tar.gz
rmdir src/ProgNet.Service/publish
dotnet publish src/ProgNet.Service/ProgNet.Service.csproj -o ./publish
tar -czvf ProgNet.Service.tar.gz -C src/ProgNet.Service/publish .
# Upload zip file
ssh [email protected] "mkdir -p prognet" && scp ProgNet.Service.tar.gz [email protected]:prognet
# On Server
sudo mkdir -p /opt/prognet/service/1
sudo tar -xf prognet/ProgNet.Service.tar.gz --directory /opt/prognet/service/1
sudo mkdir -p /var/log/prognet/service
# Create service user
sudo useradd -s /sbin/nologin prognet-user
# Give permissions to prognet-user
sudo chown -R prognet-user:prognet-user /opt/prognet/service
sudo chmod 775 /opt/prognet/service/1
sudo chown -R prognet-user:prognet-user /var/log/prognet/
sudo chmod -R g+w /opt/prognet/service/1
sudo chmod g+w /var/log/prognet/service
# Setup systemd
cd /etc/systemd/system
sudo touch prognet-service.service
sudo vim prognet-service.service
#### copy to vim
[Unit]
Description=ProgNet Service
[Service]
ExecStart=/bin/dotnet/dotnet ProgNet.Service.dll
# If you're using the Amazon EC2 instance the right line is:
# ExecStart=/usr/share/dotnet/dotnet ProgNet.Service.dll
WorkingDirectory=/opt/prognet/service/1
User=prognet-user
Group=prognet-user
Restart=always
RestartSec=3
SyslogIdentifier=prognet-service
PrivateTmp=true
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
###
# Reload config
sudo systemctl daemon-reload
# Enable, Start and view status
sudo systemctl enable prognet-service.service
sudo systemctl start prognet-service.service
sudo systemctl status prognet-service.service
# View journal
sudo journalctl --unit prognet-service --follow