English
Systemd Service
Overview
The Service page lets you run your own long-running programs, such as a Node.js app, a queue worker or a bot, as systemd services on the server. FlashPanel reads every service directly from the server, so what you see always matches what is actually running. You can create, edit, start, stop and restart services, choose whether they start with the server, and view their logs.
To open it, go to the server management page and select Service in the menu.
Service List
The table lists the services that FlashPanel manages on this server, sorted by name, 10 per page. Use the selector at the bottom of the table to show more rows per page or all of them. Click a column title to sort by that column.
Each row shows:
- Expand arrow (first column): Click it, or anywhere on the row, to view the full unit file content of the service. Click again to collapse it.
- Name: The service name. Two markers can appear next to it:
- A lock icon: a system service provided by an installed package (for example
redisornginx). It cannot be edited or deleted from the server. - An application label (for example Meilisearch, MTProxy or Tomcat): the service was created by that application.
- A lock icon: a system service provided by an installed package (for example
- Status: The current state of the service.
- Active (green): The service is running.
- Inactive (grey): The service is stopped.
- Failed (red): The service stopped because of an error. Check its logs.
- Other states such as
activating(orange) mean the service is changing state.
- Boot: Turn the switch on to start the service automatically when the server boots.
- Actions:
- Start, Stop and Restart buttons control the service right away. Start is greyed out while the service is running, and Stop is greyed out while it is stopped.
- View Log opens the service logs (see View Logs). The button turns red when the service has failed.
- The ⋮ menu holds Edit, Clone and Delete. See the sections below.
While an action is running on a service, only that row is locked. You can keep working with the other services.
At the top of the table:
- Type in the Search box to filter services by name.
- Click Status and tick Active, Failed or Inactive to show only the services in those states. Each option shows how many services it contains, so you can spot failed services at a glance.
- Click Boot and tick Enabled or Disabled to filter by the Boot setting. It works together with the Status filter, for example to find services that are stopped but still start with the system.
- The selected values appear on the filter button. Click Clear filters to clear the search and all filters.
Click the refresh button next to Add existing to read all services again from the server.
The status of every service refreshes automatically every 30 seconds while the page is open. Hover over the refresh button to see the time of the last update.
If the server cannot be reached, an error message appears above the table. Check that the server is online, then click the refresh button.
Control Several Services at Once
- Tick the checkboxes of the services you want to control. A bar with the number of selected services appears at the bottom of the screen.
- Click one of the buttons in that bar: Start, Stop, Restart, Start with the system, Do not start with the system or Delete Selected. Hover over a button to see its name. Click the close button on the left to deselect all.
Delete Selected opens the same confirmation as deleting a single service, with the names of the selected services. Delete from server is only available when every selected service can be deleted from the server; otherwise choose Remove from list.
The action is sent to all selected services at once and the selection is cleared. While a selected service is still running an action, the buttons are hidden to avoid sending it twice. If some services fail, a single message lists them with the reason.
View Logs
Click the View Log button of the service. The logs open in a floating window that you can move, resize or minimize.
Choose the log to read:
- Output: The program's standard output log file.
- Error: The program's error log file.
- Journal: The systemd journal of the service. It is always available, even for services that do not write their logs to a file.
Output and Error only appear when the service writes its logs to files.
Choose how many Lines to show, from the most recent ones.
Turn on Auto refresh to reload the logs every 5 seconds, or click the refresh button to reload them once.
Colors written by your program are displayed as in a terminal. The path of the log file is shown at the top right of the window.
Create a Service
- Click Create Service.
- Enter a Name: letters, numbers, dashes and underscores only, up to 32 characters, not starting with a number. Uppercase letters and accents are converted, for example
MyAppis saved asmyapp. The name that will be saved is shown under the field. - Fill in the service on one of the two tabs:
Quick setup (default): Fill in the form and the unit file is generated for you.
- Command: The full command that starts your program, beginning with the absolute path of the program, for example
/usr/bin/node /home/flashpanel/app/server.js. This is required. - Working directory: The folder the program runs in. Optional. Click the field to pick the folder of a site on the server, or type any other path.
- Run as user: The Linux user that runs the program. Defaults to
root. - Restart policy: Always restart, Restart on failure or Never restart.
- Environment variables: One variable per line, for example
NODE_ENV=production. Optional.
Logs are written to
/var/log/services/<name>.logand/var/log/services/<name>-error.log.- Command: The full command that starts your program, beginning with the absolute path of the program, for example
Unit file: Edit the unit file content yourself in the editor. Open this tab after Quick setup to see or fine-tune the generated content. Going back to Quick setup generates the content again from the form.
- Set
ExecStartto the command that starts your program. A warning appears below the editor whileExecStartis empty. - The log file paths are filled in from the service name and update automatically when you change the name, until you edit the content yourself.
- Set
- Tick Boot with the system to start the service automatically when the server boots.
- Click Create Service.
The service is created and started. Follow the progress in the event that appears.
Manage a Service That Already Exists on the Server
To manage services you created on the server yourself, for example over SSH:
- Click Add existing. The window lists the services in
/etc/systemd/systemthat are not in the list yet, with their status and Boot setting. Click Refresh in the window to read them again. - Tick the services you want to manage.
- Click Add to list.
The services are added to the list as they are. Nothing changes on the server: they keep running and keep their Boot setting.
A service is greyed out and cannot be ticked when its name does not follow the naming rules: lowercase letters, numbers, dashes and underscores only, up to 32 characters, not starting with a number. Rename its unit file on the server to add it. System services provided by installed packages do not appear in this window.
You can also click Create Service and enter the name of an existing service. It is added to the list unchanged, unless you tick Overwrite if exists to replace its content with yours. The content must then contain ExecStart, and the service is restarted with the new content.
Edit a Service
- Open the ⋮ menu of the service and click Edit.
- Edit the unit file content in the editor. The content must contain
ExecStartin the[Service]section, otherwise Update Service stays disabled. - Click Update Service.
The service is restarted with the new content. The Boot setting does not change.
The service name cannot be changed. To rename a service, clone it under the new name, then delete the old one.
Clone a Service
- Open the ⋮ menu of the service you want to copy and click Clone.
- Enter a name for the new service. The content of the original service is copied into the editor, and the log file paths and
Descriptionare renamed to the new name as you type. - Update the rest of the content if needed, for example the port or the working directory.
- Boot with the system is ticked by default. Untick it if needed.
- Click Create Service.
Delete a Service
- Open the ⋮ menu of the service and click Delete.
- Choose one of the options:
- Remove from list: Stop managing the service here. Nothing changes on the server and the service keeps running. You can add it back later with Add existing.
- Delete from server: Stop the service, turn off start with the system, then remove its unit file and its log files under
/var/logfrom the server.
- Click the confirm button.
Delete from server is not available for:
- System services provided by installed packages (lock icon).
- Services created by an application that is still installed. Uninstall the application instead.
Notes & Warnings
- Note: System services provided by installed packages, such as
nginx,ssh,mysqlorredis, cannot be created, edited or deleted here. This protects the services your server depends on. - Note: If a service's unit file is deleted directly on the server, the service is removed from the list the next time you open the page.
- Note: Each log view shows at most the last 1 MB of the log.
- Warning: Delete from server cannot be undone. The unit file and log files are removed permanently. Use Remove from list if you only want to stop managing the service.
- Warning: Make sure each service writes to its own log files. Deleting a service from the server also deletes the log files set in its unit file, even if another service writes to the same files.
- Warning: Services run with the permissions of the
Userset in the unit file. Avoidrootunless your program really needs it.