How to configure autostart scripts on RHEL 7.x
Remove old startup scripts in the
/etc/init.ddirectory:cd /etc/init.d mkdir old_dir mv mongod mysql nginx php-fpm postgresql-9.4 riak riak-cs rpa_manager s3emu solr stanchion tabula tomcat tomcat-nlp vault wfagent ./old_dirCreate
.servicefiles for each WorkFusion (WF) service:cd /etc/systemd/system for i in {mongod,mysql,nexus,nginx,php-fpm,postgresql-9.4,rpa_manager,s3emu,solr,tabula,tomcat-nlp,tomcat,vault,wfagent}; do touch wf-$i.service;doneEdit each
.servicefile respectively:################### [Unit] Description=Control tomcat After=wf-mysql.service wf-mongod.service wf-postgresql-9.4.service wf-s3emu.service wf-solr.service wf-nexus.service wf-vault.service wf-nginx.service wf-php-fpm.service wf-tomcat-nlp.service wf-rpa_manager.service wf-tabula.service wf-wfagent.service [Service] Type=oneshot ExecStart=/usr/bin/su - wfuser -c "export HOME=$(getent passwd wfuser | cut -d: -f6); /opt/workfusion/apps/webapps/tomcat.init start" ExecStop=/usr/bin/su - wfuser -c "export HOME=$(getent passwd wfuser | cut -d: -f6); /opt/workfusion/apps/webapps/tomcat.init stop" ExecReload=/usr/bin/su - wfuser -c "export HOME=$(getent passwd wfuser | cut -d: -f6); /opt/workfusion/apps/webapps/tomcat.init restart" RemainAfterExit=yes [Install] WantedBy=multi-user.target ###################
note
The option After= in the [Unit] section allows to configure service dependencies. The service defined in the [Service] section will wait till all services mentioned in the After line are up and running. Only after that, it will start.
note
You can download the set of .service files to the server via the following link.
Enable the ewly created
.servicescripts.for i in {mongod,mysql,nexus,nginx,php-fpm,postgresql-9.4,rpa_manager,s3emu,solr,tabula,tomcat-nlp,tomcat,vault,wfagent}; do /bin/systemctl enable wf-$i.service;doneor
for i in `ls wf-*`; do /bin/systemctl enable $i;doneAnd after that:
systemctl daemon-reloadCheck that startup scripts are activated properly:
ll /etc/systemd/system/multi-user.target.wants/wf-* systemctl -a|grep wf-