You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Scott <up...@yahoo.com.INVALID> on 2021/04/19 06:25:47 UTC

systemd auto start and stop

Does anyone have a working james.service systemd file that will run correctly on Ubuntu 20.04 with the new Apache James 3.6?

I tried both configurations in this thread with failed results:  http://mail-archives.apache.org/mod_mbox/james-server-user/201901.mbox/%3Ce29099de-ec85-43f7-d25e-b7bde062868d@marcchamberlin.com%3E

The journalctl log message just said "Exit code" with either of those configurations. This was the last one I tried before I gave up:

[Unit]
Description=Apache James 3.6 Mail Server
After=network.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/java"
WorkingDirectory=/usr/local/james/bin 
ExecStart=/usr/local/james/bin/james start
ExecStop=/usr/local/james/bin/james stop
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target


What would happen when I would run "systemctl start james" was that it would start, run for 10-15 seconds, and then stop.

For those running James in a prod environment, what are you doing to auto-start and stop it on system reboots?

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: systemd auto start and stop

Posted by Garry Hurley <ga...@gmail.com>.
Okay. If you are not getting to wrapper.log, it is the service API that is failing. I am not sure on Debian ,but on RHEL and CentOS, you should be able to do service james status or system to status james and see what is happening. The other way is to look at journalctl -xe. 

Sent from my iPhone

> On Apr 20, 2021, at 1:24 AM, Scott <up...@yahoo.com.invalid> wrote:
> 
> Nothing ever got logged to either the james.log file or the wrapper.log file. Like it didn't make it far enough in the starting process to log anything.
> 
> The link the previous responder posted offered a helpful tip. ( https://dmatthews.org/java_email.html )
> 
> On that James help page, he said:  "I have a couple of reasons for favouring the use of run.sh over the james command. Firstly I found that although james start and james console works fine on a fedora linux system, it fails in a way mysterious to me on debian."
> 
> I think I will try his method of using run.sh instead of "james start". That prevents a clean stop/shutdown from occurring in an automated way, but I guess everything is a trade-off.
> 
> Thanks all for the help and assistance.
> 
> 
> 
> On Monday, April 19, 2021, 8:19:57 AM PDT, Garry Hurley <ga...@gmail.com> wrote: 
> 
> 
> 
> 
> 
> What are the errors in your James.log file?
> 
> By the way, I had set up my James files to locate my logs in a configurable directory by setting up a ‘log_dir’ variable in the properties file and locating all logs in log_dir. That makes it easier for organizations that are required to move their logs to a certain directory for monitoring and sharing purposes when the James admin is separate from the server admin
> 
> Sent from my iPhone
> 
>> On Apr 19, 2021, at 2:26 AM, Scott <up...@yahoo.com.invalid> wrote:
>> 
>> Does anyone have a working james.service systemd file that will run correctly on Ubuntu 20.04 with the new Apache James 3.6?
>> 
>> I tried both configurations in this thread with failed results:  http://mail-archives.apache.org/mod_mbox/james-server-user/201901.mbox/%3Ce29099de-ec85-43f7-d25e-b7bde062868d@marcchamberlin.com%3E
>> 
>> The journalctl log message just said "Exit code" with either of those configurations. This was the last one I tried before I gave up:
>> 
>> [Unit]
>> Description=Apache James 3.6 Mail Server
>> After=network.target
>> [Service]
>> Type=forking
>> Environment="JAVA_HOME=/usr/local/java"
>> WorkingDirectory=/usr/local/james/bin 
>> ExecStart=/usr/local/james/bin/james start
>> ExecStop=/usr/local/james/bin/james stop
>> RestartSec=10
>> Restart=always
>> [Install]
>> WantedBy=multi-user.target
>> 
>> 
>> What would happen when I would run "systemctl start james" was that it would start, run for 10-15 seconds, and then stop.
>> 
>> For those running James in a prod environment, what are you doing to auto-start and stop it on system reboots?
>> 
>> Scott
> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: systemd auto start and stop

Posted by Scott <up...@yahoo.com.INVALID>.
Nothing ever got logged to either the james.log file or the wrapper.log file. Like it didn't make it far enough in the starting process to log anything.

The link the previous responder posted offered a helpful tip. ( https://dmatthews.org/java_email.html )

On that James help page, he said:  "I have a couple of reasons for favouring the use of run.sh over the james command. Firstly I found that although james start and james console works fine on a fedora linux system, it fails in a way mysterious to me on debian."

I think I will try his method of using run.sh instead of "james start". That prevents a clean stop/shutdown from occurring in an automated way, but I guess everything is a trade-off.

Thanks all for the help and assistance.



On Monday, April 19, 2021, 8:19:57 AM PDT, Garry Hurley <ga...@gmail.com> wrote: 





What are the errors in your James.log file?

By the way, I had set up my James files to locate my logs in a configurable directory by setting up a ‘log_dir’ variable in the properties file and locating all logs in log_dir. That makes it easier for organizations that are required to move their logs to a certain directory for monitoring and sharing purposes when the James admin is separate from the server admin

Sent from my iPhone

> On Apr 19, 2021, at 2:26 AM, Scott <up...@yahoo.com.invalid> wrote:
> 
> Does anyone have a working james.service systemd file that will run correctly on Ubuntu 20.04 with the new Apache James 3.6?
> 
> I tried both configurations in this thread with failed results:  http://mail-archives.apache.org/mod_mbox/james-server-user/201901.mbox/%3Ce29099de-ec85-43f7-d25e-b7bde062868d@marcchamberlin.com%3E
> 
> The journalctl log message just said "Exit code" with either of those configurations. This was the last one I tried before I gave up:
> 
> [Unit]
> Description=Apache James 3.6 Mail Server
> After=network.target
> [Service]
> Type=forking
> Environment="JAVA_HOME=/usr/local/java"
> WorkingDirectory=/usr/local/james/bin 
> ExecStart=/usr/local/james/bin/james start
> ExecStop=/usr/local/james/bin/james stop
> RestartSec=10
> Restart=always
> [Install]
> WantedBy=multi-user.target
> 
> 
> What would happen when I would run "systemctl start james" was that it would start, run for 10-15 seconds, and then stop.
> 
> For those running James in a prod environment, what are you doing to auto-start and stop it on system reboots?
> 
> Scott

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: systemd auto start and stop

Posted by Scott <up...@yahoo.com.INVALID>.
In case anyone else gets stuck in this problem, I wanted to share what I did to get James to automatically startup on Ubuntu 20.04 at boot time. Run the following commands (1-3):

1. nano /usr/local/sbin/james-start

    #!/bin/bash
    export JAVA_HOME=/usr/local/java
    cd /usr/local/james/bin
    nohup ./run.sh &

 2. chmod 750 /usr/local/sbin/james-start

3. crontab -e

    add the following line:  @reboot /usr/local/sbin/james-start


I did those logged in as root. Rebooted the system and James was automatically started.

I understand that this is not the best way to do this. I have found no clean way to shutdown James using the above method (I just killed the process), so we hope that when the system is shut down, James is not in the middle of writing mail. Maybe there is a built-in file or database integrity check when writing? But, I can say that it works, and thank DMatthews for his "perfect java email server" page.



On Monday, April 19, 2021, 8:19:57 AM PDT, Garry Hurley <ga...@gmail.com> wrote: 


What are the errors in your James.log file?

By the way, I had set up my James files to locate my logs in a configurable directory by setting up a ‘log_dir’ variable in the properties file and locating all logs in log_dir. That makes it easier for organizations that are required to move their logs to a certain directory for monitoring and sharing purposes when the James admin is separate from the server admin

Sent from my iPhone

> On Apr 19, 2021, at 2:26 AM, Scott <up...@yahoo.com.invalid> wrote:
> 
> Does anyone have a working james.service systemd file that will run correctly on Ubuntu 20.04 with the new Apache James 3.6?
> 
> I tried both configurations in this thread with failed results:  http://mail-archives.apache.org/mod_mbox/james-server-user/201901.mbox/%3Ce29099de-ec85-43f7-d25e-b7bde062868d@marcchamberlin.com%3E
> 
> The journalctl log message just said "Exit code" with either of those configurations. This was the last one I tried before I gave up:
> 
> [Unit]
> Description=Apache James 3.6 Mail Server
> After=network.target
> [Service]
> Type=forking
> Environment="JAVA_HOME=/usr/local/java"
> WorkingDirectory=/usr/local/james/bin 
> ExecStart=/usr/local/james/bin/james start
> ExecStop=/usr/local/james/bin/james stop
> RestartSec=10
> Restart=always
> [Install]
> WantedBy=multi-user.target
> 
> 
> What would happen when I would run "systemctl start james" was that it would start, run for 10-15 seconds, and then stop.
> 
> For those running James in a prod environment, what are you doing to auto-start and stop it on system reboots?
> 
> Scott

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: systemd auto start and stop

Posted by Garry Hurley <ga...@gmail.com>.
What are the errors in your James.log file?

By the way, I had set up my James files to locate my logs in a configurable directory by setting up a ‘log_dir’ variable in the properties file and locating all logs in log_dir. That makes it easier for organizations that are required to move their logs to a certain directory for monitoring and sharing purposes when the James admin is separate from the server admin

Sent from my iPhone

> On Apr 19, 2021, at 2:26 AM, Scott <up...@yahoo.com.invalid> wrote:
> 
> Does anyone have a working james.service systemd file that will run correctly on Ubuntu 20.04 with the new Apache James 3.6?
> 
> I tried both configurations in this thread with failed results:  http://mail-archives.apache.org/mod_mbox/james-server-user/201901.mbox/%3Ce29099de-ec85-43f7-d25e-b7bde062868d@marcchamberlin.com%3E
> 
> The journalctl log message just said "Exit code" with either of those configurations. This was the last one I tried before I gave up:
> 
> [Unit]
> Description=Apache James 3.6 Mail Server
> After=network.target
> [Service]
> Type=forking
> Environment="JAVA_HOME=/usr/local/java"
> WorkingDirectory=/usr/local/james/bin 
> ExecStart=/usr/local/james/bin/james start
> ExecStop=/usr/local/james/bin/james stop
> RestartSec=10
> Restart=always
> [Install]
> WantedBy=multi-user.target
> 
> 
> What would happen when I would run "systemctl start james" was that it would start, run for 10-15 seconds, and then stop.
> 
> For those running James in a prod environment, what are you doing to auto-start and stop it on system reboots?
> 
> Scott
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: systemd auto start and stop

Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>What are the errors in your James.log file?
>

None that I can recall; I've not looked at James for a while.

--
David Matthews
mail@dmatthews.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org