Created Run as a Service Ubuntu (markdown)
parent
8e5bb85d4e
commit
9965d4cc37
|
@ -0,0 +1,52 @@
|
||||||
|
How to run proxy as service on Ubuntu, and logging to specific file instead of spamming /var/log/syslog with ticker updated ;)
|
||||||
|
|
||||||
|
/etc/systemd/system/gbproxy.service
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=gbproxy
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
# The configuration file application.properties should be here:
|
||||||
|
WorkingDirectory=/PATH/TO/GunbotProxy
|
||||||
|
ExecStart=/usr/bin/java -jar GunbotProxyCommunity.jar
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
SyslogIdentifier=gbproxy
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
/etc/rsyslog.d/40-gbproxy.conf
|
||||||
|
```
|
||||||
|
if $programname == 'gbproxy' then /var/log/gbproxy.log
|
||||||
|
& stop
|
||||||
|
```
|
||||||
|
|
||||||
|
/etc/logrotate.d/gbproxy
|
||||||
|
```
|
||||||
|
/var/log/gbproxy.log
|
||||||
|
{
|
||||||
|
rotate 7
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
olddir /var/log/gbproxy
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
sharedscripts
|
||||||
|
postrotate
|
||||||
|
invoke-rc.d rsyslog rotate >/dev/null 2>&1 || true
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After making these files, run following commands.
|
||||||
|
touch /var/log/gbproxy.log
|
||||||
|
chown syslog /var/log/gbproxy.log
|
||||||
|
mkdir /var/log/gbproxy
|
||||||
|
systemctl restart rsyslog
|
||||||
|
systemctl enable gbproxy.service
|
||||||
|
systemctl start gbproxy
|
||||||
|
|
||||||
|
Now it will start proxy automatically at boot and logs console output to /var/log/gbproxy.log instead of /var/log/syslog
|
||||||
|
also it will rotate gbproxy.log daily to /var/log/gbproxy/ and keep last 7 logs(compressed).
|
Loading…
Reference in New Issue