help with running play2 application on centos as daemon using systemd

66 views
Skip to first unread message

何德才

unread,
Aug 23, 2016, 1:27:20 PM8/23/16
to play-framework
Hi all,
 I'm going to deploy our project on centos 7 and I want to run our application as daemon but failed, can any one help me, thanks.

systemd config

[Unit]


Description=web


After=network.target


[Service]


ExecStart=/path/to/bin/app -Dconfig.resource=production2.conf -Dpidfile.path=/run/app.pid -Dlogger.resource=conf/prod-logger2.xml>/var/log/app.log


[Install]


WantedBy=multi-user.target



errors

(code=exited, status=255)


 Main PID: 34693 (code=exited, status=255)


8 24 00:46:02 web1 chugui_erp[34693]: at java.io.FileInputStream.open(FileInputStream.java:195)


8 24 00:46:02 web1 chugui_erp[34693]: at java.io.FileInputStream.<init>(FileInputStream.java:138)


8 24 00:46:02 web1 chugui_erp[34693]: at java.io.FileInputStream.<init>(FileInputStream.java:93)


8 24 00:46:02 web1 chugui_erp[34693]: at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)


8 24 00:46:02 web1 chugui_erp[34693]: at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)


8 24 00:46:02 web1 chugui_erp[34693]: at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:48)


8 24 00:46:02 web1 chugui_erp[34693]: ... 12 more


8 24 00:46:02 web1 systemd[1]: chugui_erp2.service: main process exited, code=exited, status=255/n/a


8 24 00:46:02 web1 systemd[1]: Unit chugui_erp2.service entered failed state.


8 24 00:46:02 web1 systemd[1]: chugui_erp2.service failed.



何德才

unread,
Aug 23, 2016, 2:57:36 PM8/23/16
to play-framework
BTW, I want to log the stdout to my own log file not the sys log.

在 2016年8月24日星期三 UTC+8上午1:27:20,何德才写道:

何德才

unread,
Aug 23, 2016, 2:57:36 PM8/23/16
to play-framework
Hi,
 I changed the config file to
 

ExecStart=/var/www/chugui_erp_2/bin/chugui_erp -Dconfig.resource=production2.conf -Dpidfile.path=/run/chugui_erp2.pid -Dlogger.resource=prod-logger2.xml > /var/log/chugui_erp/chugui_erp2_error.log

and got the errors as bellow

8 24 01:50:32 web1 systemd[1]: Started chugui erp web.


8 24 01:50:32 web1 systemd[1]: Starting chugui erp web...


8 24 01:50:33 web1 chugui_erp[36452]: Bad root server path: /var/www/chugui_erp_2/>

Igmar Palsenberg

unread,
Sep 5, 2016, 4:43:05 AM9/5/16
to Play Framework
 

ExecStart=/path/to/bin/app -Dconfig.resource=production2.conf -Dpidfile.path=/run/app.pid -Dlogger.resource=conf/prod-logger2.xml>/var/log/app.log


Don't use relative paths. Also, redirects won't work, configure a logger.resource file.


Igmar

何德才

unread,
Sep 8, 2016, 7:07:08 AM9/8/16
to Play Framework
I want to log the server exception such as NullpointException to a log file not the /var/log/messages file, what can I do?

在 2016年9月5日星期一 UTC+8下午4:43:05,Igmar Palsenberg写道:

Igmar Palsenberg

unread,
Sep 11, 2016, 10:39:38 AM9/11/16
to Play Framework
 
I want to log the server exception such as NullpointException to a log file not the /var/log/messages file, what can I do?

Write a proper logback.xml file : 

<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
          <file>/var/log/play/application.log</file>
     <encoder>
       <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
     </encoder>
   </appender>

   <logger name="play" level="INFO"/>
   <root level="WARN">
    <appender-ref ref="FILE" />
  </root>
</configuration>

何德才

unread,
Sep 24, 2016, 9:27:42 AM9/24/16
to Play Framework
Thank you, I'll try it.

在 2016年9月11日星期日 UTC+8下午10:39:38,Igmar Palsenberg写道:
Reply all
Reply to author
Forward
0 new messages