Linux Learning-Set the Seafile startup script to boot up service

Source: Internet
Author: User
Tags seafile

Sometimes, the Linux software and programs we install are not installed through Yum, but are compiled or otherwise installed. Sometimes it is necessary to set the program as a service to achieve the purpose of booting up.

I set up the Seafile network on the public cloud and the server, when I restart the cloud server, the Seafile program does not start automatically, I need to execute the script in the relevant directory to start.

Use a soft connection to the/root/directory for two scripts for easy execution

Now use the service to add these two scripts to boot


Create a SYSTEMD service file /etc/systemd/system/seafile.service
Vim/etc/systemd/system/seafile.service ======================= content is as follows ========================[unit]description= seafile# add Mysql.service or Postgresql.service depending on your database to the line Belowafter=network.target[service] Type=oneshotexecstart=/home/cloud_storage/seafile-server-latest/seafile.sh startexecstop=/home/cloud_storage/ Seafile-server-latest/seafile.sh stopremainafterexit=yesuser=seafilegroup=seafile[install]wantedby= Multi-user.target


This file consists of three parts: Unit\service\install

[Unit] is primarily to resolve dependencies. Common add-requires, after, if this dependency is optional, then wants, after. Dependencies are often used on services rather than (target), so the above-mentioned httpd rely on only a few target, so there is no requires and wants to appear.

The [service] can choose several different ways to start the services, and the startup mode is set by the type parameter.

Type=simple (default): Systemd thinks the service will start immediately. The service process does not fork. If the service is to start another service, do not use this type to start unless the service is socket-activated.

Type=forking:systemd believes that when the service process is fork and the parent process exits, the service starts successfully. For a regular daemon (daemon), use this type to start up unless you are sure that this startup mode does not meet your requirements. Use this startup type to specify pidfile= at the same time so that SYSTEMD can track the main process of tracking.

Type=oneshot: This option applies to services that perform only one task and then exit immediately. You may need to set remainafterexit=yes at the same time so that Systemd still thinks the service is active after the service process exits.

Type=notify: Same as Type=simple, but the contract service sends a signal to SYSTEMD when it is ready. The implementation of this notification is provided by libsystemd-daemon.so.

Type=dbus: If the specified busname appears on the Dbus system bus when it is started in this manner, SYSTEMD considers the service ready

[Install]

Wantedby=multi-user.target Multi-user boot



Create a SYSTEMD service file /etc/systemd/system/seahub.service
vim/etc/systemd/system/seahub.service======================= content is as follows ========================[unit]description= Seafile hubafter=network.target seafile.service[service]# Change start to start-fastcgi if you want to run Fastcgiexecstar T=/home/cloud_storage/seafile-server-latest/seahub.sh startexecstop=/home/cloud_storage/seafile-server-latest/ Seahub.sh Stopuser=seafilegroup=seafiletype=oneshotremainafterexit=yes[install]wantedby=multi-user.target


Reload Service

Systemctl daemon-reloadsystemctl enable seafile.servicesystemctl enable Seahub.service


Linux Learning-Set the Seafile startup script to boot up service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.