Apisix-dashboard: feat: support run `manager api` as OS service

Created on 21 Nov 2020  路  12Comments  路  Source: apache/apisix-dashboard

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • [ ] Question or discussion
  • [ ] Bug
  • [ ] Requirements
  • [x] Feature or performance improvement
  • [ ] Other

Requirements or improvement

  • Please describe your requirements or improvement suggestions.
backend enhancement stale

Most helpful comment

hii @nic-chen thanks for the heads up,
its working perfectly now,
latest logs in reverse order

-- Logs begin at Mon 2021-03-15 21:16:03 IST, end at Fri 2021-03-26 17:12:41 IST. --
Mar 26 17:12:09 turing manager-api[571177]: Logfile : /home/bisakh/Desktop/OSS/apisix-dashboard/output/logs/error.log
Mar 26 17:12:09 turing manager-api[571177]: Loglevel: warn
Mar 26 17:12:09 turing manager-api[571177]: Listen  : 127.0.0.1:9000
Mar 26 17:12:09 turing manager-api[571177]: GitHash : efdb869
Mar 26 17:12:09 turing manager-api[571177]: Version : 2.4
Mar 26 17:12:09 turing manager-api[571177]: The manager-api is running successfully!
Mar 26 17:12:09 turing systemd[1]: Started Manager-API service.
Mar 26 17:12:09 turing systemd[1]: Starting Manager-API service...

it was causing by
PermissionsStartOnly=true which was overriding user & group info to provide syslog access over the generated logs(stdout & stderr).
so putting

User=<>
Group=<>

after syslog initialization (which was put before the statement by me earlier), solves it.
Thanks, pushing the changes soon.

All 12 comments

in 2.3?

You mean systemd and supervisord?

Not sure, I mean would this issue be resolved in M2.3?

@nic-chen @tokers It depends on building the package for the specific OS, eg: ubuntu, centos.

I think we can remove milestone 2.3.

@nic-chen @tokers It depends on building the package for the specific OS, eg: ubuntu, centos.

I think we can remove milestone 2.3.

OK

any plan?

Hello guys, can I give it a try to demonize the manager_api which includes making the necessary change in the main program (terminating on SIGTERM, SIGKILL & reloading configurations on SIGHUP) & create it as a systemd service in Linux?
Thank you.

Hello guys, can I give it a try to demonize the manager_api which includes making the necessary change in the main program (terminating on SIGTERM, SIGKILL & reloading configurations on SIGHUP) & create it as a systemd service in Linux?
Thank you.

sure, PR is welcome!

Hii everyone, I have opened a draft PR. Though it is not fully complete, I would love to have this reviewed by you all.
Currently, the config is facing a write permission error to write logs in error.log file
Here's the last log in reverse ordering

-- Logs begin at Mon 2021-03-15 21:16:03 IST, end at Wed 2021-03-24 23:52:48 IST. -- Mar 24 23:42:50 turing systemd[1]: Stopped Manager-API service. Mar 24 23:42:45 turing systemd[1]: manager-api.service: Failed with result 'exit-code'. Mar 24 23:42:45 turing systemd[1]: manager-api.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/Desktop/OSS/apisix-dashboard/api/cmd/manager/main.go:27 +0x2b Mar 24 23:42:45 turing manager-api[377717]: main.main() Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/go/pkg/mod/github.com/spf13/[email protected]/command.go:800 Mar 24 23:42:45 turing manager-api[377717]: github.com/spf13/cobra.(*Command).Execute(...) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/go/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2fe Mar 24 23:42:45 turing manager-api[377717]: github.com/spf13/cobra.(*Command).ExecuteC(0xc0004f2c80, 0xc000000180, 0xc000031f78, 0x407d85) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/go/pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x47c Mar 24 23:42:45 turing manager-api[377717]: github.com/spf13/cobra.(*Command).execute(0xc0004f2c80, 0xc0001181b0, 0x0, 0x0, 0xc0004f2c80, 0xc0001181b0) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/Desktop/OSS/apisix-dashboard/api/cmd/managerapi.go:76 +0xbb Mar 24 23:42:45 turing manager-api[377717]: github.com/apisix/manager-api/cmd.NewManagerAPICommand.func1(0xc0004f2c80, 0x1721268, 0x0, 0x0, 0x0, 0x0) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/Desktop/OSS/apisix-dashboard/api/internal/log/zap.go:39 Mar 24 23:42:45 turing manager-api[377717]: github.com/apisix/manager-api/internal/log.InitLogger(...) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/Desktop/OSS/apisix-dashboard/api/internal/log/zap.go:43 +0x3f Mar 24 23:42:45 turing manager-api[377717]: github.com/apisix/manager-api/internal/log.GetLogger(0x0, 0x3) Mar 24 23:42:45 turing manager-api[377717]: /home/bisakh/Desktop/OSS/apisix-dashboard/api/internal/log/zap.go:103 +0x208 Mar 24 23:42:45 turing manager-api[377717]: github.com/apisix/manager-api/internal/log.fileWriter(0x0, 0x0, 0x0) Mar 24 23:42:45 turing manager-api[377717]: goroutine 1 [running]: Mar 24 23:42:45 turing manager-api[377717]: panic: couldn't open sink "/home/bisakh/Desktop/OSS/apisix-dashboard/output/logs/error.log": open /home/bisakh/Desktop/OSS/apisix-dashboard/output/logs/error.log: permission denied Mar 24 23:42:45 turing systemd[1]: Started Manager-API service. Mar 24 23:42:45 turing systemd[1]: Starting Manager-API service... Mar 24 23:42:45 turing systemd[1]: Stopped Manager-API service. Mar 24 23:42:45 turing systemd[1]: manager-api.service: Scheduled restart job, restart counter is at 74. Mar 24 23:42:40 turing systemd[1]: manager-api.service: Failed with result 'exit-code'.
is this issue regarding writer, _, err := zap.Open(logPath) for not providing any permission/umask explicitly.

It would be great if you guys could provide any sort of guide/help. Thank you.

cc @starsz @nic-chen to help when you have time.

hi @bisakhmondal
Need to confirm, is the owner of the logs directory and running manager-api the same user?

hii @nic-chen thanks for the heads up,
its working perfectly now,
latest logs in reverse order

-- Logs begin at Mon 2021-03-15 21:16:03 IST, end at Fri 2021-03-26 17:12:41 IST. --
Mar 26 17:12:09 turing manager-api[571177]: Logfile : /home/bisakh/Desktop/OSS/apisix-dashboard/output/logs/error.log
Mar 26 17:12:09 turing manager-api[571177]: Loglevel: warn
Mar 26 17:12:09 turing manager-api[571177]: Listen  : 127.0.0.1:9000
Mar 26 17:12:09 turing manager-api[571177]: GitHash : efdb869
Mar 26 17:12:09 turing manager-api[571177]: Version : 2.4
Mar 26 17:12:09 turing manager-api[571177]: The manager-api is running successfully!
Mar 26 17:12:09 turing systemd[1]: Started Manager-API service.
Mar 26 17:12:09 turing systemd[1]: Starting Manager-API service...

it was causing by
PermissionsStartOnly=true which was overriding user & group info to provide syslog access over the generated logs(stdout & stderr).
so putting

User=<>
Group=<>

after syslog initialization (which was put before the statement by me earlier), solves it.
Thanks, pushing the changes soon.

Was this page helpful?
0 / 5 - 0 ratings