Systemctl is starting the process as a user: I use a wrapper script to set ENV 
variables then start using the activemq script

[Unit]
Description=MQ Broker
After = network.target

[Service]
Type=forking
ExecStart=/var/www/mqbroker/bin/startMQBroker.sh
User=svcinvenio

[Install]
WantedBy = multi-user.target

-----------------------------------------
This is the process:
svcinve+  12260      1  6 15:40 ?        00:00:05 /usr/bin/java 
-Dlog4j.dir=/var/tmp/amq/log -Dlog_instance=ip-172-31-51-195.ec2.internal 
-Dlog_component=mqbroker -Dcom.sun.management.jmxremote.rmi.port=51521 
-Dcom.sun.management.jmxremote.port=51520 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Djava.rmi.server.hostname=ec2-107-23-187-26.compute-1.amazonaws.com 
-Dcom.sun.management.jmxremote 
-Djavax.net.ssl.keyStore=/var/tmp/amq/conf/broker.ks 
-Djavax.net.ssl.keyStorePassword=password 
-Djavax.net.ssl.trustStore=/var/tmp/amq/conf/broker.ts 
-Djavax.net.ssl.trustStorePassword=password -Djava.awt.headless=true 
-Djava.io.tmpdir=/var/tmp/amq/tmp 
-Dactivemq.classpath=/var/tmp/amq/conf:/var/tmp/amq/../lib/: 
-Dactivemq.home=/var/www/mqbroker/apache-activemq-5.16.2 
-Dactivemq.base=/var/tmp/amq -Dactivemq.conf=/var/tmp/amq/conf 
-Dactivemq.data=/var/tmp/amq/data -jar 
/var/www/mqbroker/apache-activemq-5.16.2/bin/activemq.jar start 
xbean:file:/var/tmp/amq/conf/activemq-nojournal-persistent-SSL.xml

-----------------------------------------
These are the ports.. First 3 are the ActiveMQ process.. it should have a 4th 
for 61617 that is the entry point for clients.. but since it is in slave mode 
nothing is started on that port. The other two are tomcat
tcp6       0      0 :::51520                :::*                    LISTEN      
12260/java
tcp6       0      0 :::51521                :::*                    LISTEN      
12260/java
tcp6       0      0 :::38114                :::*                    LISTEN      
12260/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      
1390/java
tcp6       0      0 :::8080                 :::*                    LISTEN      
1390/java

---------------------------------------
Here is the owner of the lock file
 lsof /var/tmp/amq/data/kahadb/lock
COMMAND   PID       USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
java    12260 svcinvenio  132uw  REG  202,2        8 88135148 
/var/tmp/amq/data/kahadb/lock


Data directory:
ls -lrt
total 40
-rw-r--r--. 1 svcinvenio svcinvenio        8 Oct 14 15:40 lock
-rw-r--r--. 1 svcinvenio svcinvenio 33554432 Oct 14 15:40 db-1.log
-rw-r--r--. 1 svcinvenio svcinvenio    12304 Oct 14 15:46 db.redo
-rw-r--r--. 1 svcinvenio svcinvenio    12288 Oct 14 15:46 db.data
Dan Cosio

 Wired Informatics
265 Franklin St Ste 1702
Boston, MA 02110
http://wiredinformatics.com
[email protected]




> On Oct 13, 2021, at 1:11 AM, Tim Bain <[email protected]> wrote:
> 
> Is your systemctl-launched ActiveMQ running as root or another user? Can that 
> user manually create that file from the command line?
> 
> When the file is created under systemctl, is it owned by the user the broker 
> is running as? Are you able to tell which process created the lock file? Does 
> any process have the lock file open? If so, is it your broker?
> 
> Is the filesystem the lock file lives on a network filesystem or a local one? 
> If remote, what NFS version does it use? 
> 
> Tim 
> 
> On Mon, Oct 11, 2021, 8:27 AM Dan Cosio <[email protected] 
> <mailto:[email protected]>> wrote:
> This is the only java process running on the machine.. this only happens when 
> starting the broker using systemctl..If I start it using sudo -u on the 
> command line it starts up as expected(no slave mode)
> Dan Cosio
> 
>  Wired Informatics
> 265 Franklin St Ste 1702
> Boston, MA 02110
> http://wiredinformatics.com <http://wiredinformatics.com/>
> [email protected] <mailto:[email protected]>
> 
> 
> 
> 
>> On Oct 11, 2021, at 5:22 AM, Jean-Baptiste Onofre <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Hi,
>> 
>> The broker is in slave mode when another process/broker has the lock on 
>> kahadb.
>> 
>> If you check in kahadb folder, you should have a lock file (in your case, it 
>> seems to be in /var/tmp/amq/data),  so, either you have already a broker 
>> running, either the broker doesn’t have to take/create the lock in the 
>> kahadb folder.
>> 
>> Regards
>> JB
>> 
>>> Le 9 oct. 2021 à 15:42, Dan Cosio <[email protected] 
>>> <mailto:[email protected]>> a écrit :
>>> 
>>> 
>>> Using ActiveMQ 5.16.2
>>> I'm seeing strange behavior when starting ActiveMQ using systemctl. The 
>>> server starts in slave mode:
>>> [pid: ][main] 08 Oct 2021 18:15:46  INFO XBeanBrokerFactory$1 - Refreshing 
>>> org.apache.activemq.xbean.XBeanBrokerFactory$1@68bbe345: startup date [Fri 
>>> Oct 08 18:15:46 UTC 2021]; root of context hierarchy
>>> [pid: ][main] 08 Oct 2021 18:15:46  INFO XBeanXmlBeanDefinitionReader - 
>>> Loading XML bean definitions from URL 
>>> [file:/var/tmp/amq/conf/activemq-nojournal-persistent-SSL.xml]
>>> [pid: ][main] 08 Oct 2021 18:15:46  INFO XBeanXmlBeanDefinitionReader - 
>>> Loading XML bean definitions from URL [file:/var/tmp/amq/conf/jetty.xml]
>>> [pid: ][main] 08 Oct 2021 18:15:47  INFO BrokerService - Using Persistence 
>>> Adapter: KahaDBPersistenceAdapter[/var/tmp/amq/data/kahadb]
>>> [pid: ][KahaDB Index Free Page Recovery] 08 Oct 2021 18:15:47  INFO 
>>> PageFile - Page File: /var/tmp/amq/data/kahadb/db.data. Recovering pageFile 
>>> free list due to prior unclean shutdown..
>>> [pid: ][KahaDB Index Free Page Recovery] 08 Oct 2021 18:15:47  INFO 
>>> PageFile - Page File: /var/tmp/amq/data/kahadb/db.data. Recovered pageFile 
>>> free list of size: 0
>>> [pid: ][main] 08 Oct 2021 18:15:47  INFO MessageDatabase - KahaDB is 
>>> version 7
>>> [pid: ][main] 08 Oct 2021 18:15:47  INFO PListStoreImpl - 
>>> PListStore:[/activemq-data/broker-persistent-SSL/tmp_storage] started
>>> [pid: ][main] 08 Oct 2021 18:15:47  INFO SharedFileLocker - Database 
>>> activemq-data/broker-persistent-SSL/scheduler/lock is locked by another 
>>> server. This broker is now in slave mode waiting a lock to be acquired
>>> 
>>> If I start the broker using sudo -u <user> it starts correctly.
>>> This is configured to run SSL with persistence:
>>>    <broker xmlns="http://activemq.apache.org/schema/core 
>>> <http://activemq.apache.org/schema/core>"
>>> 
>>> 
>>> useJmx="true"
>>> 
>>> 
>>> persistent="true"
>>> 
>>> 
>>> dedicatedTaskRunner="false"
>>> 
>>> 
>>> schedulerSupport="true"
>>> 
>>> 
>>> brokerName="broker-persistent-SSL">
>>> This is the process:
>>> /usr/bin/java -Dlog4j.dir=/var/tmp/amq/log 
>>> -Dlog_instance=ip-172-31-51-195.ec2.internal 
>>> -Dinvenio_log_component=mqbroker -Dcom.sun.management.jmxremote.port=51520 
>>> -Dcom.sun.management.jmxremote.ssl=false 
>>> -Dcom.sun.management.jmxremote.authenticate=false 
>>> -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote 
>>> -Djavax.net.ssl.keyStore=/var/tmp/amq/conf/broker.ks 
>>> -Djavax.net.ssl.keyStorePassword=<password> 
>>> -Djavax.net.ssl.trustStore=/var/tmp/amq/conf/broker.ts 
>>> -Djavax.net.ssl.trustStorePassword=<password> -Djava.awt.headless=true 
>>> -Djava.io.tmpdir=/var/tmp/amq/tmp 
>>> -Dactivemq.classpath=/var/tmp/amq/conf:/var/tmp/amq/../lib/: 
>>> -Dactivemq.home=/var/www/mqbroker/apache-activemq-5.16.2 
>>> -Dactivemq.base=/var/tmp/amq -Dactivemq.conf=/var/tmp/amq/conf 
>>> -Dactivemq.data=/var/tmp/amq/data -jar 
>>> /var/www/mqbroker/apache-activemq-5.16.2/bin/activemq.jar start 
>>> xbean:file:/var/tmp/amq/conf/activemq-nojournal-persistent-SSL.xml
>>> 
>>> I've removed the lock file and restarted. There are no other brokers on 
>>> this machine
>>> Can anyone give me a hint as to what may be causing this?
>>> 
>>> 
>>> Dan Cosio
>>> 
>>> <wired-logo.png> Wired Informatics
>>> 265 Franklin St Ste 1702
>>> Boston, MA 02110
>>> http://wiredinformatics.com <http://wiredinformatics.com/>
>>> [email protected] <mailto:[email protected]>
>>> 
>>> 
>>> 
>>> 
>> 
> 
> <wired-logo.png>

Reply via email to