# R
library(data.table)
library(parallel)
set.seed(123)
n_rows <- 1e7
n_cols <- 1000
## memory black hole!!! change it if necessary, however, you need to require a high level of memory usage (about 1/30 to 1/10 of your usable memory) to achieve significant results in the subsequent tests
dt <- data.table(matrix(runif(n_rows * n_cols), nrow = n_rows, ncol = n_cols))
memory_usage <- object.size(dt)
format(memory_usage, units = "auto")
worker_function <- function(data) {
row_sums <- rowSums(data)
## wait about 30s and run shell command to test when process sleep
Sys.sleep(1000)
return(row_sums)
}
n_threads <- 10
results <- mclapply(1:n_threads, function(x) worker_function(dt), mc.cores = n_threads)
我正在开展一个项目,需要使用 SSM 文档将 Spring Boot 应用程序 Pet Clinic 安装到 Ubuntu 22 服务器上。我已附加 Systems Manager 运行文档。错误是...
我正在开展一个项目,需要使用 SSM 文档将 Spring Boot 应用程序 Pet Clinic 到 Ubuntu 22 服务器上。我已附加 Systems Manager 运行文档。以下错误来自命令 sudo journalctl -u spring-petclinic.service 。我尝试授予任何和所有访问权限,以 root 身份运行,但仍然不起作用。
关于如何让该应用程序保持运行,您有什么想法吗?
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Failed with result 'exit-code'.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Scheduled restart job, restart counter is at 3.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: Stopped Spring PetClinic Application.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: Started Spring PetClinic Application.
May 17 21:52:36 ip-10-0-4-141 java[7076]: Error: Unable to access jarfile /clinic/spring-petclinic/target/*.jar
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Main process exited, code=exited, status=1/FAILURE
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Failed with result 'exit-code'.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Scheduled restart job, restart counter is at 4.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: Stopped Spring PetClinic Application.
May 17 21:52:36 ip-10-0-4-141 systemd[1]: Started Spring PetClinic Application.
May 17 21:52:36 ip-10-0-4-141 java[7077]: Error: Unable to access jarfile /clinic/spring-petclinic/target/*.jar
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Main process exited, code=exited, status=1/FA
---
schemaVersion: '2.2'
description: Install Java 17 and run the Spring PetClinic application
parameters: {}
mainSteps:
- name: InstallJava17
action: aws:runShellScript
inputs:
runCommand:
- |
#!/bin/bash
# Check if Java is installed
if java -version > /dev/null 2>&1; then
echo "Java is installed. No need to restart"
else
echo "Java is not installed. Restarting after install...."
# Update package lists
sudo apt-get update
# Install OpenJDK 17
sudo apt-get install -y openjdk-17-jdk
# Verify Java installation
java -version
exit 194
fi
- name: DownloadApplication
action: aws:runShellScript
inputs:
runCommand:
- |
#!/bin/bash
# clean the environment file
cat /dev/null > /etc/environment
# set the full path
echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:\$JAVA_HOME/bin\"" | sudo tee -a /etc/environment
# grab the java home and set it in the environment
JAVA_HOME=$(sudo update-alternatives --config java | grep -o -E '/usr/lib/jvm/[a-zA-Z0-9-]+')
echo "JAVA_HOME=\"$JAVA_HOME\"" | sudo tee -a /etc/environment
# update the variables
source /etc/environment
echo "whoami?"
sudo whoami
# Create and move into new folder
sudo mkdir /clinic
cd /clinic
# Download the repository
echo "# Download the repository"
sudo git clone https://github.com/spring-projects/spring-petclinic.git
# Move into the folder
echo "# Move into the folder"
cd spring-petclinic
# Start the Maven build
echo "# Start the Maven build"
./mvnw package
- name: CreateSystemdService
action: aws:runShellScript
inputs:
runCommand:
- |
#!/bin/bash
# clean the environment file
cat /dev/null > /etc/environment
# set the full path
echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:\$JAVA_HOME/bin\"" | sudo tee -a /etc/environment
# grab the java home and set it in the environment
JAVA_HOME=$(sudo update-alternatives --config java | grep -o -E '/usr/lib/jvm/[a-zA-Z0-9-]+')
echo "JAVA_HOME=\"$JAVA_HOME\"" | sudo tee -a /etc/environment
# update the variables
source /etc/environment
# Create systemd service unit
echo "# Create systemd service unit"
sudo tee /etc/systemd/system/spring-petclinic.service <<EOF
[Unit]
Description=Spring PetClinic Application
After=network.target
echo "THIS IS THE PATH"
echo $PATH
echo "THIS IS THE JAVA_HOME"
echo $JAVA_HOME
[Service]
ExecStart=/usr/lib/jvm/java-17-openjdk-amd64/bin/java -jar /clinic/spring-petclinic/target/*.jar
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
echo "whoami?"
sudo whoami
# Reload systemd and start the service
echo "# Reload systemd and start the service"
echo "whoami?"
sudo whoami
echo "daemon is reloading"
sudo systemctl daemon-reload
echo "whoami?"
sudo whoami
echo "enabling spring-petclinic"
sudo systemctl enable spring-petclinic
echo "whoami?"
sudo whoami
echo "starting spring-petclinic"
sudo systemctl start spring-petclinic