From 9965d4cc373665915d218a9252a6a22f2182b5f6 Mon Sep 17 00:00:00 2001 From: taniman Date: Thu, 6 Jul 2017 23:28:01 +0200 Subject: [PATCH] Created Run as a Service Ubuntu (markdown) --- Run-as-a-Service-Ubuntu.md | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Run-as-a-Service-Ubuntu.md diff --git a/Run-as-a-Service-Ubuntu.md b/Run-as-a-Service-Ubuntu.md new file mode 100644 index 0000000..d7b4be8 --- /dev/null +++ b/Run-as-a-Service-Ubuntu.md @@ -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).