Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:systemd_service_script [2018/03/23 14:49] billdozor [The Service Unit File] |
linux_wiki:systemd_service_script [2019/05/25 23:50] (current) |
||
---|---|---|---|
Line 118: | Line 118: | ||
Jan 24 10:31:08 server1.local logger[17693]: | Jan 24 10:31:08 server1.local logger[17693]: | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Example: Docker Compose ===== | ||
+ | |||
+ | Putting docker-compose commands into a service. | ||
+ | |||
+ | / | ||
+ | <code bash> | ||
+ | [Unit] | ||
+ | Description=Docker Compose Containers | ||
+ | Requires=docker.service | ||
+ | After=docker.service | ||
+ | |||
+ | [Service] | ||
+ | Type=oneshot | ||
+ | RemainAfterExit=yes | ||
+ | ExecStart=/ | ||
+ | ExecStop=/ | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Example: Apache HTTPD Compiled ===== | ||
+ | |||
+ | Creating a service unit file for a locally compiled and installed Apache web server. | ||
+ | |||
+ | \\ | ||
+ | / | ||
+ | <code bash> | ||
+ | [Unit] | ||
+ | Description=Apache Web Server | ||
+ | After=network.target remote-fs.target nss-lookup.target | ||
+ | |||
+ | [Service] | ||
+ | Type=forking | ||
+ | PIDFile=/ | ||
+ | ExecStart=/ | ||
+ | ExecStop=/ | ||
+ | ExecReload=/ | ||
+ | PrivateTmp=true | ||
+ | LimitNOFILE=infinity | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | Reload systemd< | ||
+ | |||
+ | \\ | ||
+ | Enable/ | ||
+ | systemctl start httpd-local</ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Override File ====== | ||
+ | |||
+ | Override files are used when you want to modify part or all of a RPM/system provided systemd unit file. Use over rides instead of directly modifying system unit files, as they could be reverted upon next related package update. | ||
+ | |||
+ | System Provided unit files: / | ||
+ | |||
+ | ===== Override Example: docker service ===== | ||
+ | |||
+ | System provided file to over ride: / | ||
+ | |||
+ | * Create a directory to contain the over ride file (named after the original unit file name)< | ||
+ | * Create the over ride file< | ||
+ | |||
+ | [Service] | ||
+ | EnvironmentFile= | ||
+ | EnvironmentFile=-/ | ||
+ | ExecStart= | ||
+ | ExecStart=/ | ||
+ | * Each variable with a blank assignment (' | ||
+ | |||
+ | * Reload the systemd daemon for the override file to be picked up<code bash> | ||
+ | |||
+ | * Restart the service | ||
+ | |||
+ | ===== Override Example: rpcbind service ===== | ||
+ | |||
+ | System provided file to over ride: / | ||
+ | |||
+ | * Create a directory to contain the over ride file (named after the original unit file name, but add a " | ||
+ | * Create the over ride file (NAME.conf)< | ||
+ | |||
+ | [Service] | ||
+ | ExecStart= | ||
+ | ExecStart=/ | ||
+ | * Each variable with a blank assignment (' | ||
+ | |||
+ | * Reload the systemd daemon for the override file to be picked up<code bash> | ||
+ | |||
+ | * Restart the service | ||
---- | ---- | ||