Below is my supervisord.conf file. One would think that it would start zookeeper but it does not.
ZK works manually if I run sh /var/chef/cache/zookeeper-3.4.5/bin/zkServer.sh start-foreground
# -*- conf -*-
[include]
files = *.supervisor
[supervisord]
pidfile = /var/run/supervisord.pid
nodaemon=false
[supervisorctl]
serverurl=unix:///var/run/supervisord.sock ; use a unix:// URL for a unix socket
[unix_http_server]
file = /var/run/supervisord.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:zookeeper]
command= sh /var/chef/cache/zookeeper-3.4.5/bin/zkServer.sh start-foreground
process_name=%(program_name)s
autostart=true
autorestart=true
stdout_logfile=/var/log/zookeeper.log
stopsignal=KILL
#stopasgroup = true
#killasgroup = true
#stdout_logfile = /tmp/zookeeper.out
#stderr_logfile = /tmp/zookeeper.err
pidfile = /var/run/zookeeper.pid
[group:zookeeper_server]
programs=zookeeper
Use the explicit command without calling the shell in the command for instance:
command=/opt/java/bin/java -Dzookeeper.log.dir="." -cp "/home/app/zookeeper/bin/../build/classes:/home/app/zookeeper/bin/../build/lib/*.jar:/home/app/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/app/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/app/zookeeper/bin/../lib/netty-3.2.2.Final.jar:/home/app/zookeeper/bin/../lib/log4j-1.2.15.jar:/home/app/zookeeper/bin/../lib/jline-0.9.94.jar:/home/app/zookeeper/bin/../zookeeper-3.4.5.jar:/home/app/zookeeper/bin/../src/java/lib/*.jar:/home/app/zookeeper/bin/../conf:" -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/home/app/zookeeper/bin/../conf/zoo.cfg"
With java in /opt/java/ and zookeeper in /home/app/zookeeper
To find it you can launch the shell and copy-paste the command line.
It seems supervisor has sometimes troubles with shell scripts and python scripts depending on os / vm etc. I didn't find the reason yet.
But if you use a standalone command it works pretty well.
I execute zookeeper as foreground process in supervisord, disable rolling logs in zookeeper log4j configuration (only console) and use supervisord rotation. It does the job.
Related
I'm trying to run Supervisord from Docker, but having trouble for running Java with -javaagent parameter. It gives below error
Error opening zip file or JAR manifest missing : /usr/apps/executor.jar
It works otherwise if I simply omit -javaagent.
I've tried with below option, but still same error
"-javaagent:/usr/apps/executor.jar"
-javaagent:"/usr/apps/executor.jar"
// Supervisor.conf
[supervisord]
nodaemon = true
user = root
loglevel = debug
[program:helloworld]
user = root
directory = /usr/apps
# this one will work
# command = /usr/bin/env java -jar /usr/apps/HelloWorld.jar
# this one will NOT work
command = /usr/bin/env java -javaagent:"/usr/apps/executor.jar" -jar /usr/apps/HelloWorld.jar
# this one will NOT work
#command = /usr/bin/env java "-javaagent:/usr/apps/executor.jar" -jar /usr/apps/HelloWorld.jar
# this one will NOT work
#command = /usr/bin/env java -javaagent:/usr/apps/executor.jar -jar /usr/apps/HelloWorld.jar
// DockerFile
FROM openjdk:11
USER root
COPY ./HelloWorld.jar /usr/apps/HelloWorld.jar
CMD ["/usr/bin/supervisord","-n"]
Appreciate any help to get this to work...
(From the comments.)
Error opening zip file or JAR manifest missing : /usr/apps/executor.jar
would imply that the file isn't in the container, so it can't be read. (This can be verified with e.g. docker build -t myimage . and docker run -it --rm myimage ls -la /usr/apps; if executor.jar isn't there, it's... not there.)
You'll need to make sure the file truly is in there with an ADD or COPY command.
My file /etc/init/myserver.conf used to work on Ubuntu 12.04 using sudo service myserver start,stop, restart. I copied it to /etc/init/ on Ubuntu 18.04 and it did not work. How can I fix it?
# masterserver - start master server service
description "Service that starts master.sh"
author "<hadjieff>"
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Essentially lets upstart know the process will detach itself to the background
expect fork
# Run before process
pre-start script
# Put bash code here if necessary
end script
# Start the process
script
cd /home/hadjieff/hadjieff/server
sudo java -Djava.security.policy=security.policy -Djava.rmi.server.hostname=192.168.1.91 -cp . -jar Registar.jar --xbee=true --test=false
end script
I noticed that my servers have both supervisord.conf and supervisor.conf located at:
/etc/supervisord.conf
/etc/supervisor/supervisor.conf
The installed package is:
supervisor 3.2.0-2
OS version: Ubuntu 14.04/16.04
Running lsof|grep supervisor shows that none of the processes had neither of them open
Does anyone know the difference?
Which of the conf files is the one to take place?
When running supervisord or supervisorctl, the program will first check the current working directory ($CWD, or the directory from where you invoke the command) for a supervisord.conf file. When absent, it will look for /etc/supervisord.conf. The docs will tell you more about it: http://supervisord.org/configuration.html
You also can specify the exact location of the config file by using the -c flag: supervisord -c path/to/your/file.conf.
So, in answer to your question: /etc/supervisord.conf is the one. However, if you'd like to use the other config file, you would run supervisord -c /etc/supervisor/supervisor.conf.
I am trying to run a java process with supervisord and am getting:
couldn't exec /var/application/start_tester: ENOEXEC
The contents of start_tester is:
java -Duser.dir=/var/application/ -cp /var/application/application.jar:/var/application/toepoke.jar com.application.Application
When I run the script from the console the app runs as expected. Here is my supervisor config
[program:application_tester]
directory=/var/application
command=/var/application/start_tester ; the program (relative uses PATH, can take args)
log_stdout=true ; if true, log program stdout (default true)
log_stderr=true ; if true, log program stderr (def false)
logfile=/var/log/application_tester.log
When I run the script from the console this is the output:
[root#monitor application]# ./start_tester
20131009 203657: application starting up.
20131009 203657 (33): version 2.2.3
Your file needs to be executable. So either:
You should chmod +x it to set the executable bit.
Put a shebang at the start of the file. Not having this is what caused the ENOEXEC.
or
Modify your config file to something like command=sh /var/application/start_tester.
In most cases a shebang is usually missing.
- #!/usr/bin/env bash
- #!/bin/bash
- #!/bin/sh
- #!/bin/sh -
Once you add the shebang to your gunicorn_start file (in case of DJANGO),
restart the supervisor
sudo systemctl enable supervisor
sudo systemctl restart supervisor
I have a perl script that I need to run once at startup with an argument under my user account.
So when I boot the system up it needs to execute a command like this,
./path/to/script.pl start
Any ideas?
You could use a line in your crontab (crontab -e)
To run a command at startup:
edit /etc/crontab
Add the following line:
#reboot root perl ./path/to/script.pl start
^^^ Runs as root. Change "root" to "BlackCow" to run as BlackCow
Or, you could use upstart (add a .conf file to /etc/init/). Here's a copy and paste from my notes:
Use upstart to run a daemon at reboot/start
e.g. /etc/init/prestocab.conf:
#!upstart
description "node.js server"
author "BlackCow"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
script
export HOME="/root"
exec sudo -u root /usr/local/bin/node /home/prestocab/prestocab.com/www/socket.io/server.js 2>&1 >> /var/log/prestocab.log
end script
To use:
start prestocab
stop prestocab
restart prestocab
#
You might want to use some sort of process monitor to restart the daemon if it crashes
Depends on what init you are using, if your version of Ubuntu is using upstart
you have to configure the appropriate Upstart start scripts, if not
the rc scripts based on your runlevel. Check update-rc.d.
On Ubuntu, the simplest way is to add this line to your /etc/rc.local file (before the exit 0 line, substituting username with your own user name):
su -c "./path/to/script.pl start" username &