Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you do "configtest" and "graceful" with systemd/systemctl

(trick question, you cannot, use old init.d scripts)



>trick question, you cannot

  [Unit]
  Description=The Apache HTTP Server
  After=remote-fs.target nss-lookup.target
  [Service]
  Type=notify
  EnvironmentFile=/etc/sysconfig/httpd
  ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
  ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
  ExecStop=/usr/sbin/httpd $OPTIONS -k graceful-stop
  KillSignal=SIGCONT
  PrivateTmp=true
  [Install]
  WantedBy=multi-user.target
and 'apachectl configtest' or 'nginx -t' iirc


Why would I do a `configtest` with a thing that starts or stops a service in the first place? That's what `apachectl configtest` or whatever is for.

I wouldn't expect to go to Windows' list of services, right click one and run arbitrary commands either.


How do you do "configtest" and "graceful" with old init.d scripts?

    # /etc/init.d/mysqld configtest
    Usage: /etc/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload}

    # /etc/init.d/mysqld graceful
    Usage: /etc/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload}


configtest and graceful are "commands" used by other scripts such as httpd (apache) and nginx scripts which can take alternate signals to do other actions

but even in your example, condrestart, try-restart, those aren't supported by pure systemd scripts - however if you were using the init.d version you could do the easy-to-remember/type service mysqld condrestart

Fortunately with 7.0 you can keep using the old init.d scripts and custom commands, hopefully that will never go away with any of the later 7.x versions (I don't see why).


I'm not a systemd expert, but for configtest, you could add a 'Config' parameter and patch systemd to record the hash of each config file at start time. From then on, all .services, ever, that supplied their Config would be able to do a configtest and condrestart. DRY.

What's 'graceful'? A particular signal?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: