Shihira / gnome-extension-quicktoggler

DEPRECATED: Switched to KDE, so goodbye friends. Toggling services, launching apps in one click.
https://extensions.gnome.org/extension/1077/quick-toggler/
40 stars 9 forks source link

"wrong" detection of service status #1

Closed andcoz closed 8 years ago

andcoz commented 8 years ago

I configured three different systemd entries in my config file. The detection of service status does not work for two of them (postgresql and oracle-xe).

I suppose that the problem is that the word "running" is not in the output of the systemctl status command although the service is running.

My entries.json file:

{
  "entries": [
    {
      "type": "systemd",
      "title": "Apache Httpd 2.4",
      "unit": "apache2"
    }, {
      "type": "systemd",
      "title": "Postgre SQL 9.1",
      "unit": "postgresql"
    }, {
      "type": "systemd",
      "title": "Oracle 11.2 XE",
      "unit": "oracle-xe"
    }
  ]
}

The output of service httpd status ; service postgresql status ; service oracle-xe status when all the services are running.

apache2.service - The Apache Webserver
   Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled)
   Active: active (running) since Fri 2016-05-06 08:40:02 CEST; 6h ago
 Main PID: 2036 (httpd2-prefork)
   Status: "Total requests: 8; Current requests/sec: 0; Current traffic:   0 B/sec"
[ snip snip ]

postgresql.service - LSB: Start the PostgreSQL master daemon
   Loaded: loaded (/etc/init.d/postgresql)
   Active: active (exited) since Fri 2016-05-06 08:40:07 CEST; 6h ago
  Process: 2044 ExecStart=/etc/init.d/postgresql start (code=exited, status=0/SUCCESS)
[ snip snip ]

oracle-xe.service - LSB: Oracle Database 11g Express Edition
   Loaded: loaded (/etc/init.d/oracle-xe)
   Active: active (exited) since Fri 2016-05-06 15:07:37 CEST; 13min ago
  Process: 5653 ExecStop=/etc/init.d/oracle-xe stop (code=exited, status=0/SUCCESS)
  Process: 7113 ExecStart=/etc/init.d/oracle-xe start (code=exited, status=0/SUCCESS)
[ snip snip ]

I'm using OpenSuSE 13.2 and gnome-shell 3.14 and, yes, I changed the metadata.json file.

Shihira commented 8 years ago

@andcoz Thank you so much for your report.

It seems to be a predictable behaviour. You can see core.js:139 to find out how it works. If you are eager for a work-around, you are recommended to try the more flexible type toggler and set command_on, command_off and detector based on your demand. And If you are willing to help me improve the extension, is there a properer grep regular expression that works for you? Maybe grep 'Active: activ[ei]' (i for "activing")?

Shihira commented 8 years ago

@andcoz Some slight changes are made in the latest commit a608c62d7d211a2200c8a416675b79c8556f5362 . Does it meet your demand? More feedbacks are welcome.

andcoz commented 8 years ago

I just pulled the latest version and It works like a charm. Thank you.

On my system, the Active: line of systemctl status changes as follow when i stop and then start again a service (that forks and exits):

   Active: active (exited) since Sun 2016-05-08 18:17:41 CEST; 56s ago
   Active: deactivating (stop) since Sun 2016-05-08 18:18:40 CEST; 3s ago
   Active: inactive (dead) since Sun 2016-05-08 18:18:48 CEST; 2s ago
   Active: activating (start) since Sun 2016-05-08 18:18:59 CEST; 2s ago
   Active: active (exited) since Sun 2016-05-08 18:19:07 CEST; 2s ago

So IMHO, the regex Active: activ[ei]should work well.