complete-computing-environment/async_forever.org

29 lines
1.2 KiB
Org Mode

:PROPERTIES:
:ID: cce/async_forever
:ROAM_ALIASES: async-forever
:END:
#+TITLE: Running Things in Emacs Forever
#+filetags: :CCE:Emacs:Code:
#+PROPERTY: header-args :mkdirp yes :results none
#+PROPERTY: header-args:emacs-lisp :tangle async-forever.el
#+ARROYO_EMACS_MODULE: async-forever
#+ARCOLOGY_KEY: cce/async-forever
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
#+ARCOLOGY_ALLOW_CRAWL: t
#+begin_src emacs-lisp :exports none
(provide 'cce/async-forever)
#+end_src
In [[id:cce/cce][The Complete Computing Environment]] there are a number of processes that I run that I want to have more visibility in to than if they were running as SystemD User Services. They may die, they may start to spawn errors, I want to know if it's failing or misbehaving. Right now this is mainly used in my OfflineIMAP setup, but I maintain it here and use it for one-off solutions.
#+begin_src emacs-lisp
(defun cce/async-forever (command buffer-name &optional seconds)
"Run a command in an async buffer forever"
(save-window-excursion
(async-shell-command (concat "while true; do " command "; sleep " (prin1-to-string (or seconds 5)) "; done")
(get-buffer-create buffer-name))))
#+end_src