-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM golang:alpine | ||
|
||
WORKDIR /opt/sagoo-iot-server/ | ||
|
||
COPY ./config/ /opt/sagoo-iot-server/config | ||
|
||
COPY ./curl.sh /opt/sagoo-iot-server/ | ||
COPY ./entrypoint.sh /opt/sagoo-iot-server/ | ||
COPY ./sagoo-admin /opt/sagoo-iot-server/ | ||
|
||
COPY ./entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
RUN chmod +x /opt/sagoo-iot-server/sagoo-admin | ||
|
||
COPY ./resource/public /opt/sagoo-iot-server/resource/public/ | ||
|
||
EXPOSE 8200 | ||
|
||
CMD ["/bin/sh", "-c", "sleep 50 && /entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
WORKSPACE=$(cd "$(dirname "$0")" || exit; pwd) | ||
cd "$WORKSPACE" || exit | ||
|
||
readonly app='sagoo-admin' | ||
readonly pidfile="var/$app.pid" | ||
readonly logfile="var/$app.log" | ||
|
||
mkdir -p var | ||
|
||
check_pid() { | ||
if [[ -f $pidfile ]]; then | ||
local pid=$(cat "$pidfile") | ||
if [[ -n $pid ]]; then | ||
local running=$(ps -p "$pid" | grep -c -v "PID TTY") | ||
return "$running" | ||
fi | ||
fi | ||
return 0 | ||
} | ||
|
||
start() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
printf "%s now is running already, pid: %s\n" "$app" "$(cat "$pidfile")" | ||
return 1 | ||
fi | ||
|
||
nohup "./$app" >> "$logfile" 2>&1 & | ||
sleep 1 | ||
running=$(ps -p $! | grep -c -v "PID TTY") | ||
if [[ $running -gt 0 ]]; then | ||
echo $! > "$pidfile" | ||
printf "%s started... pid: %s\n" "$app" "$!" | ||
else | ||
printf "%s failed to start.\n" "$app" | ||
return 1 | ||
fi | ||
} | ||
|
||
stop() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
local pid=$(cat "$pidfile") | ||
kill "$pid" | ||
rm -f "$pidfile" | ||
printf "%s stopped.\n" "$app" | ||
else | ||
printf "%s is not running.\n" "$app" | ||
fi | ||
} | ||
|
||
restart() { | ||
stop | ||
sleep 1 | ||
start | ||
} | ||
|
||
status() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
printf "%s is started.\n" "$app" | ||
else | ||
printf "%s is stopped.\n" "$app" | ||
fi | ||
} | ||
|
||
tailf() { | ||
tail -f "var/*" | ||
} | ||
|
||
print_help() { | ||
printf "Usage: %s {start|stop|restart|status|tail|pid}.\n" "$0" | ||
} | ||
|
||
print_pid() { | ||
cat "$pidfile" | ||
} | ||
|
||
main() { | ||
case "$1" in | ||
"start") start ;; | ||
"stop") stop ;; | ||
"restart") restart ;; | ||
"status") status ;; | ||
"tail") tailf ;; | ||
"pid") print_pid ;; | ||
*) print_help ;; | ||
esac | ||
} | ||
|
||
main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
# 这里是其他的启动逻辑或命令 | ||
/opt/sagoo-iot-server/sagoo-admin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
sagoo-iot-open: | ||
image: sagoo-iot-open:1.0.0 | ||
restart: always | ||
container_name: sagoo-iot-open | ||
build: | ||
dockerfile: ./Dockerfile | ||
depends_on: | ||
- mysql | ||
- redis | ||
- emqx | ||
- tdengine | ||
environment: | ||
- TZ=Asia/Shanghai | ||
ports: | ||
- 8200:8200 | ||
volumes: | ||
- "./resource/public/upload_file/:/opt/sagoo-iot-server/resource/public/upload_file" | ||
- "./resource/log/:/opt/sagoo-iot-server/resource/log" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#user nobody; | ||
worker_processes 1; | ||
|
||
#error_log logs/error.log; | ||
#error_log logs/error.log notice; | ||
#error_log logs/error.log info; | ||
|
||
#pid logs/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
# '$status $body_bytes_sent "$http_referer" ' | ||
# '"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
#access_log logs/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
#keepalive_timeout 0; | ||
keepalive_timeout 65; | ||
|
||
gzip on; | ||
gzip_min_length 10k; | ||
gzip_buffers 4 16k; | ||
gzip_comp_level 6; | ||
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; | ||
gzip_vary on; | ||
gzip_proxied expired no-cache no-store private auth; | ||
gzip_disable "MSIE [1-6]\."; | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
# ssl_certificate /data/nginx/conf/vhost/cert/localhost/fullchain.pem; | ||
# ssl_certificate_key /data/nginx/conf/vhost/cert/localhost/privkey.pem; | ||
|
||
location / { | ||
root /usr/share/nginx/html/iot-ui; | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root html; | ||
} | ||
|
||
#sagoo-iot路由 | ||
location /base-api/ { | ||
proxy_set_header Connection upgrade; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_http_version 1.1; | ||
chunked_transfer_encoding off; | ||
proxy_pass http://sagoo-iot-open:8200/; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
#接⼝⽂档路由 | ||
location /base-api/swagger/api.json { | ||
proxy_pass http://sagoo-iot-open:8200/base-api/swagger/api.json; | ||
} | ||
} | ||
|
||
|
||
# another virtual host using mix of IP-, name-, and port-based configuration | ||
# | ||
#server { | ||
# listen 8000; | ||
# listen somename:8080; | ||
# server_name somename alias another.alias; | ||
|
||
# location / { | ||
# root html; | ||
# index index.html index.htm; | ||
# } | ||
#} | ||
|
||
|
||
# HTTPS server | ||
# | ||
#server { | ||
# listen 443 ssl; | ||
# server_name localhost; | ||
|
||
# ssl_certificate cert.pem; | ||
# ssl_certificate_key cert.key; | ||
|
||
# ssl_session_cache shared:SSL:1m; | ||
# ssl_session_timeout 5m; | ||
|
||
# ssl_ciphers HIGH:!aNULL:!MD5; | ||
# ssl_prefer_server_ciphers on; | ||
|
||
# location / { | ||
# root html; | ||
# index index.html index.htm; | ||
# } | ||
#} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.