gogs: systemd gogs-web-1.service not start when reboot (mariadb or mysql is not started yet)

  • Gogs version (or commit ref): [root@server-gogs ~]# rpm -q gogs gogs-0.10.1-1488280184.9d40b8a.centos7.x86_64

  • Git version: [root@server-gogs ~]# rpm -q git git-1.8.3.1-6.el7_2.1.x86_64

  • Operating system: Centos 7.3

  • Database (use [x]):

    • PostgreSQL
    • MySQL
    • SQLite
  • Can you reproduce the bug at https://try.gogs.io:

    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist (usually found in log/gogs.log): 2017/03/02 13:53:15 [TRACE] Log Mode: File (Trace) 2017/03/02 13:53:15 [ INFO] Gogs 0.10.1.0228 2017/03/02 13:53:15 [ INFO] Cache Service Enabled 2017/03/02 13:53:15 [ INFO] Session Service Enabled 2017/03/02 13:53:15 [FATAL] […s/routers/install.go:67 GlobalInit()] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: get sockopt: connection refused 2017/03/02 13:53:15 [TRACE] Log Mode: File (Trace) 2017/03/02 13:53:15 [ INFO] Gogs 0.10.1.0228 2017/03/02 13:53:15 [ INFO] Cache Service Enabled 2017/03/02 13:53:15 [ INFO] Session Service Enabled 2017/03/02 13:53:15 [FATAL] […s/routers/install.go:67 GlobalInit()] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: get sockopt: connection refused 2017/03/02 13:53:16 [TRACE] Log Mode: File (Trace) 2017/03/02 13:53:16 [ INFO] Gogs 0.10.1.0228 2017/03/02 13:53:16 [ INFO] Cache Service Enabled 2017/03/02 13:53:16 [ INFO] Session Service Enabled 2017/03/02 13:53:16 [FATAL] […s/routers/install.go:67 GlobalInit()] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: get sockopt: connection refused 2017/03/02 13:53:16 [TRACE] Log Mode: File (Trace) 2017/03/02 13:53:16 [ INFO] Gogs 0.10.1.0228 2017/03/02 13:53:16 [ INFO] Cache Service Enabled 2017/03/02 13:53:16 [ INFO] Session Service Enabled 2017/03/02 13:53:16 [FATAL] […s/routers/install.go:67 GlobalInit()] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: getsockopt: connection refused 2017/03/02 13:53:16 [TRACE] Log Mode: File (Trace) 2017/03/02 13:53:16 [ INFO] Gogs 0.10.1.0228 2017/03/02 13:53:16 [ INFO] Cache Service Enabled 2017/03/02 13:53:16 [ INFO] Session Service Enabled 2017/03/02 13:53:16 [FATAL] […s/routers/install.go:67 GlobalInit()] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: getsockopt: connection refused

Description

If I reboot the server, service gogs-web-1.service not start

Services gogs*.service must start after mysql or mariadb is started

I have add and modify ‘After=’ services entry like this:

[root@server-gogs ~]# grep Aft /etc/systemd/system/gogs.service /etc/systemd/system/gogs-web.service /etc/systemd/system/gogs-web-1.service /etc/systemd/system/gogs.service:After=mariadb.service /etc/systemd/system/gogs-web.service:After=mariadb.service gogs.service /etc/systemd/system/gogs-web-1.service:After=mariadb.service gogs-web.service

and now when I reboot the server gogs start property and work

Dario

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I can verify that the new gogs.service is working now (I did have also a mysql dependency problem on start)

However your package script seems to not include the file into packager.io (at least for the debian packages, tested with the 11.4 deb package)

instead various probably auto generated files are present in /etc/systemd/system and used by the system:

├── gogs.service ├── gogs.service.wants │ └── gogs-web.service -> /etc/systemd/system/gogs-web.service ├── gogs-web-1.service ├── gogs-web.service ├── gogs-web.service.wants │ └── gogs-web-1.service -> /etc/systemd/system/gogs-web-1.service

basically all of them do nothing really, except that gogs-web requires gogs. For example gogs.service looks as follows:

[Unit]
StopWhenUnneeded=true

[Service]
# this service is just a placeholder
ExecStart=/bin/sleep infinity

[Install]
WantedBy=multi-user.target

Especially the After= are still missing and in my case mysql is loaded after gogs and gogs will fail to start. I can add the After= After lines as proposed in 7e883f8 to this file and it works now correctly during start.

OK, I have see. Many Thanks for support, Unknwon ! Have a nice Day!!

I have post your question to ML

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/4HGAD4ZZEBA67ERJ52I45ZMUNW2D2MTD/

Tomorrow I try this feature on some my systems and let you know

Thanks Dario

OK… purpose of those files under scripts are stated already: https://github.com/gogits/gogs/tree/master/scripts

But yes, I can add another line with After=mariadb.service for people to uncomment if they need.