I want to run weechat constantly in the background so that I can ssh in and reattach to it via screen.
I'm trying to accomplish this via the following file in /etc/init/chatscreen.conf
:
description "Run a persistent weechat within a screen"
start on runlevel [2345]
respawn
setuid chat
setgid chat
exec /usr/bin/screen -S chatscreen -Dm /usr/bin/weechat
Then I run sudo initctl start chatscreen
to start the service, which prints chatscreen start/running, process 3090
.
When I run sudo initctl status chatscreen
a moment later, it prints chatscreen stop/waiting
, and no screen or weechat processes are running according to htop.
dmesg shows the following errors:
[ 5649.430032] init: chatscreen main process ended, respawning
[ 5649.454638] init: chatscreen main process ended, respawning
[ 5649.476572] init: chatscreen main process ended, respawning
...
[ 5649.608818] init: chatscreen main process ended, respawning
[ 5649.627409] init: chatscreen respawning too fast, stopped
No /var/log/upstart/chatscreen.log
file exists.
When I ssh in as the chat user and run /usr/bin/screen -S chatscreen -Dm /usr/bin/weechat
in the shell, it executes as expected. (It runs the command and blocks. I can then start another ssh session, screen -r
, /exit weechat, and the original screen command returns.)
I'm running Ubuntu Server 14.04.1 LTS 64-bit on DigitalOcean.
EDIT: I also tried using dtach instead of screen. The only difference is that I had to use expect fork
because dtach -n
forks. dtach -n
can be run without a terminal, which I thought might be a problem with screen
.
Unfortunately, I went through the same respawning cycle without any corresponding log file in /var/log/upstart
. But dmesg did say: init: chatdtach main process (1073) terminated with status 1
multiple times.