-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added option to run image with unoserver in non-interactive mode
- Loading branch information
Showing
3 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -e -u | ||
|
||
# Function to wait for unoserver to start | ||
wait_for_unoserver() { | ||
echo "Waiting for unoserver to start ..." | ||
while [ -z "$(netstat -tln | grep 2002)" ]; do | ||
sleep 1 | ||
done | ||
echo "unoserver started." | ||
echo "using: $(libreoffice --version)" | ||
} | ||
|
||
export PS1='\u@\h:\w\$ ' | ||
|
||
# default parameters for supervisord | ||
export SUPERVISOR_INTERACTIVE_CONF='/supervisor/conf/interactive/supervisord.conf' | ||
export SUPERVISOR_NON_INTERACTIVE_CONF='/supervisor/conf/non_interactive/supervisord.conf' | ||
export UNIX_HTTP_SERVER_PASSWORD=${UNIX_HTTP_SERVER_PASSWORD:-$(cat /proc/sys/kernel/random/uuid)} | ||
|
||
echo "using: $(libreoffice --version)" | ||
|
||
# if tty then assume that container is interactive | ||
if [ ! -t 0 ]; then | ||
echo "Running unoserver-docker in non-interactive." | ||
echo "For interactive mode use '-it', e.g. 'docker run -v /tmp:/data -it unoserver/unoserver-docker'." | ||
|
||
# run supervisord in foreground | ||
supervisord -c "$SUPERVISOR_NON_INTERACTIVE_CONF" | ||
else | ||
echo "Running unoserver-docker in interactive mode." | ||
echo "For non-interactive mode omit '-it', e.g. 'docker run -p 2002-2003:2002-2003 unoserver/unoserver-docker'." | ||
|
||
|
||
# run supervisord as detached | ||
supervisord -c "$SUPERVISOR_INTERACTIVE_CONF" | ||
|
||
# wait until unoserver started and listens on port 2002. | ||
wait_for_unoserver | ||
|
||
# if commands have been passed to container run them and exit, else start bash | ||
if [[ $# -gt 0 ]]; then | ||
eval "$@" | ||
else | ||
/bin/bash | ||
fi | ||
fi |
41 changes: 41 additions & 0 deletions
41
build-context/supervisor/conf/non_interactive/supervisord.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[supervisord] | ||
pidfile = /var/run/supervisord.pid | ||
nodaemon=true | ||
|
||
# Note that at log level debug, the supervisord log file will record the stderr/stdout output | ||
# of its child processes and extended info info about process state changes, | ||
# which is useful for debugging a process which isn’t starting properly. | ||
# and also makes it available using `docker logs [container]` | ||
#logfile = /var/log/supervisor/supervisord.log | ||
logfile = /dev/stdout | ||
logfile_maxbytes = 0 | ||
loglevel = info | ||
|
||
# needed for supervisor to work | ||
[unix_http_server] | ||
file = /var/run/supervisor.sock | ||
chmod = 0700 | ||
username = admin | ||
password = %(ENV_UNIX_HTTP_SERVER_PASSWORD)s | ||
|
||
# needed for supervisor to work | ||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
||
# [inet_http_server] | ||
# port = 127.0.0.1:9001 | ||
# username = admin | ||
# password = %(ENV_INET_HTTP_SERVER_PASSWORD) | ||
|
||
[supervisorctl] | ||
serverurl = unix:///var/run/supervisor.sock | ||
|
||
[program:unoserver] | ||
command = unoserver | ||
autorestart=true | ||
|
||
#stdout_logfile = /var/log/supervisor/%(program_name)s.log | ||
stdout_logfile = /dev/stdout | ||
stderr_logfile = /dev/stderr | ||
stdout_logfile_maxbytes = 0 | ||
stderr_logfile_maxbytes = 0 |