JConsole Config - jconsole

in JBoss' run.bat, add:
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -
Dcom.sun.management.jmxremote.port=9987 -
Dcom.sun.management.jmxremote.ssl=false -
Dcom.sun.management.jmxremote.authenticate=false
To start jconsole:
JDK/bin>jconsole localhost:9987

Yes, that should work. If it doesn't, then use 'ps' (or your platform's equivalent) to check whether those arguments are making it on the JVM's command line.
Was that the question?

Related

Importance of the place of CMD in Dockerfile

I have this Dockerfile that works fine, but I was told that maybe it wasn't the best way to do what I wanted :
FROM debian:jessie
RUN apt-get update && apt-get install -y lighttpd php5-cgi php5-common php5 php5-mysql php5-gd
RUN echo server.modules += \(\"mod_rewrite\"\) >> /etc/lighttpd/lighttpd.conf
CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
RUN lighty-enable-mod fastcgi-php
RUN service lighttpd restart
RUN chown -R www-data:www-data /var/www/html
As you can see, I am creating an image for a container with lighttpd and php.
My question is about the place of the CMD part in my Dockerfile. I was told that it was better to put it at the end of the file, but as you can see, I did it in the middle of mine and it worked just fine.
It does not stop the creation nor does it interfere with the service lighttpd restart in the run part below it.
Is there any best practice regarding this or is this normal? Could I create a Dockerfile with my CMD just after the apt-get install?
Thanks for your answers regarding my question and sorry for my english if there is any big mistakes.
I believe it's more of a logical preference, no need to define the command when the image isn't ready yet. There is an added convenience that debugging with the CMD or ENTRYPOINT set to a shell may make debugging a failed build a little easier. But otherwise, the last ENTRYPOINT and/or CMD modifies the config of the image and gets inherited to all child images (each line of your Dockerfile).
It shouldn't matter where you put the CMD entry in terms of Docker using that as the default command (plus Docker will use the last one if there is more than one). Where it might make a difference is if you were trying to structure your build in order to optimize caching the layers. I.e., you want to put anything that is likely to change lower down in the Dockerfile.
I think it's more convention to put it last and makes it easier to read. Is there a specific reason in your case you don't want to put it last?

Tesseract quiet mode

Under Ubuntu I use tesseract-ocr in version 3.02. Especially the wrapper pytesseract for python, but this question is also about the commandline-tool.
In the FAQ under
https://code.google.com/p/tesseract-ocr/wiki/FAQ#How_can_I_make_the_error_messages_go_to_tesseract.log_instead_of
is written that there is a option/config-file "quiet" supressing the info line of tesseract.
However, when I call tesseract command line with this option, it says
"read_params_file: Can't open quiet"
And it is right, in the corresponding config-folder there is no "quiet"-config-file.
Where can I get it or how can I create it?
The info-line which I want to supress is: "Tesseract Open Source OCR Engine v3.02 with Leptonica".
quiet is part of tesseract-ocr repository: https://github.com/tesseract-ocr/tesseract/blob/master/tessdata/configs/quiet
The quiet config file from the other answer contains one line: debug_file /dev/null
If the config can't be used this way for some reason, you can achieve the same effect by adding -c debug_file=/dev/null somewhere before the input/output params.

supervisor program:x command expansion of environment variables $(ENV_VAR)s?

I would like to put configuration (in this case, site name) into supervisor
environment variables, for expansion in program:x command arguments. Is this supported? The documentation's wording would seem to indicate yes.
The following syntax is not working for me on supervisor-3.0 (excerpt of config file):
[supervisord]
environment = SITE="mysite"
[program:service_name]
command=/path/to/myprog/myservice /data/myprog/%(ENV_SITE)s/%(ENV_SITE)s.db %(program_name)s_%(process_num)03d
process_name=%(program_name)s_%(process_num)03d
numprocs=5
numprocs_start=1
Raises the following error:
sudo supervisord -c supervisord.conf
Error: Format string
'/path/to/myprog/myservice /data/myprog/%(ENV_SITE)s/%(ENV_SITE)s.db %(program_name)s_%(process_num)03d'
for 'command' contains names which cannot be expanded
Reading the documentation, I expected environment variables to be available for
expansion in program:x command as %(ENV_VAR)s:
http://supervisord.org/configuration.html#program-x-section-values
command:
"String expressions are evaluated against a dictionary containing the keys
group_name, host_node_name, process_num, program_name, here (the directory of
the supervisord config file), and all supervisord's environment variables
prefixed with ENV_."
Introduced: 3.0
Related:
There are open pull requests to enable expansion in additional section values:
https://github.com/Supervisor/supervisor/issues?labels=expansions&page=1&state=open
A search of goole (or SO) returns no examples of attempts to use %(ENV_VAR)s
expansion in the command section value:
https://www.google.com/search?q=supervisord+environment+expansion+in+command
I agree supervisor is not clear about this ( to me at least ).
I've found the easiest solution to execute /bin/bash -c.
In your case it would be:
command=/bin/bash -c"/path/to/myprog/myservice /data/myprog/${SITE}/${SITE}.db ..."
What do you think?
I've found inspiration here: http://blog.trifork.com/2014/03/11/using-supervisor-with-docker-to-manage-processes-supporting-image-inheritance/
You are doing it right; however, the ENV defined in your supervisord section doesn't get made available to the processes for whatever reason during configuration loading. If you start supervisord like this:
SITE=mysite supervisord
It will run correctly and expand that variable. I don't know why supervisord has issues adding to the environment and making it available to the subprocesses' config expansion. I think the environment variable is available inside the subprocess, but not when expanding variables in the subprocess config declaration.

Set JAVA_OPTS in JBOSS standalone.sh file

I have an app on jboss which logging through log4j. When I running my server through bat file (standalone.bat) logs work, but there is a problem under standalone.sh file. Here is how I set JAVA_OPTS in standalone.bat:
set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j.configuration=file:../standalone/configuration/log4j.xml"
and it works. How should I do this in standalone.sh file? I tried something like this:
JAVA_OPTS= "$JAVA_OPTS -Dlog4j.configuration=file:$JBOSS_HOME/standalone/configuration/log4j.xml"
But it doesn't work. Any ideas? Thanks in advance for your help.
The standalone.sh file will be interpreted by the shell, so it needs to be valid shell script. Remove the space after the = and you should be good. That makes the java opts line look like:
JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$JBOSS_HOME/standalone/configuration/log4j.xml"
Adding a JAVA_OPTS= line to standalone.conf (as Pawel mentioned) seems to work great. Then run standalone.sh as usual. You should see your JAVA_OPTS listed in the boot-up message.

Executable file to run java on CentOS 5

I'm trying to make a simple file so I can call it in SSH and it will start my minecraft server.
I tried making a batch file called start.bat with this code:
java -Xmx512M -Xmx512M -jar craftbukkit-1.2.5-R1.0.jar nogui
However, when I run it in SSH:
$ cd /Minecraft/server_1/
$ start.bat
The SSH returns that it is an invalid or unknown command. Is there any other way I can make a quick command/file to start my server? What file extensions would I use to get this working? It works if I paste that java command in SSH and run it, but I'd rather have a file.
The current working directory is not included in your PATH by default because it is a security risk on multiuser systems. (And a potential annoyance even on machines that are single user.) You would use ./start.bat to start the program.
Since you're using Windows naming conventions, I presume you also forgot to set the execution mode bit -- and you probably also forgot the shebang line at the top of the file.
Try this:
#!/bin/sh
java -Xmx512M -Xmx512M -jar craftbukkit-1.2.5-R1.0.jar nogui
Run chmod 500 on this file. (Strictly speaking, 555 could also work, if you didn't mind other people on the machine executing the file. But they don't need to, so don't let them.) See the chmod(1) manpage for more details on the modes -- 1 bits mean executable, 2 bits means writable, and 4 bits means readable -- thus, 5 is executable and readable.
Then, when you want to run the script, run it like this:
cd /Minecraft/server_1
./start.bat
Note the ./ -- that means the shell should start the search for the executable program in the current working directory. (It could be ./bin/start.bat if your current working directory had a bin subdirectory with a start.bat executable file.)
Is start.bat executable? Make sure you have #!/bin/sh as the first line of the file. Also the directory is probably not in in the path, so try this:
$ chmod 555 start.bat
$ ./start.bat