ubuntu 16.04 临时目录自动清理 tmpfiles.d

临时目录配置

http://manpages.ubuntu.com/manpages/bionic/man5/tmpfiles.d.5.html

临时目录清理命令

http://manpages.ubuntu.com/manpages/bionic/man8/systemd-tmpfiles.8.html


配置文件发在 /etc/tmpfiles.d/
配置文件内容示例


#Type Path             Mode UID  GID  Age Argument d     /root/download   –    –    –    1h  –


立即清理临时文件命令 sudo systemd-tmpfiles  –clean

css多行文本省略

多行文本省略

-webkit-line-clamp

示例

关键css内容

.news-zuixin p {
  font-size: 14px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-height: 20px;
  height: 40px;
}

jenkins构建+远程部署前端项目


##/bin/bash

npm config set registry https://registry.npm.taobao.org
npm install
npm run build
cd dist
rm -rf new_dist.tar.gz
tar -zcvf new_dist.tar.gz *

Publish over SSH

## /bin/bash

cd /data/jenkins-npm-demo
mkdir -p dist
rm -rf new_dist
rm -rf old_dist
mkdir new_dist
tar -zxvf new_dist.tar.gz -C ./new_dist
mv ./dist ./old_dist
mv ./new_dist ./dist

pipeline语法


sshPublisher(
  publishers: [
    sshPublisherDesc(
      configName: '192.168.7.66', 
      transfers: [
        sshTransfer(
          cleanRemote: false, 
          excludes: '', 
          execCommand: '''
            cd /data/jenkins-npm-demo
            mkdir -p dist
            rm -rf new_dist
            rm -rf old_dist
            mkdir new_dist
            tar -zxvf new_dist.tar.gz -C ./new_dist
            mv ./dist ./old_dist
            mv ./new_dist ./dist
          ''',
        execTimeout: 120000, 
        flatten: false, 
        makeEmptyDirs: false, 
        noDefaultExcludes: false, 
        patternSeparator: '[, ]+', 
        remoteDirectory: '/data/jenkins-npm-demo', 
        remoteDirectorySDF: false, 
        removePrefix: 'dist', 
        sourceFiles: 'dist/new_dist.tar.gz')], 
        usePromotionTimestamp: false, 
        useWorkspaceInPromotion: false, 
        verbose: false
      )
  ]
)

jenkins安装备忘

修改成清华镜像站

清华镜像站网址
https://mirrors.tuna.tsinghua.edu.cn/
https://www.cnblogs.com/ninefish/p/9818080.html
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
https://jenkins.pentaq.com/pluginManager/advanced


docker中运行jenkins

##/bin/bash

docker run \
  --rm \
  --name jenkins-tutorials \
  -u root \
  -p 17780:8080 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v "$HOME":/home \
  jenkinsci/blueocean

官网兼容wordpress预览文章

##nginx

    location = / {
        error_page 588 = @wordpress;
        #如果有preview参数,则返回wordpress页面
        if ($arg_preview) {
            return 588;
        }
        add_header Cache-Control "no-store";
        add_header Pragma "No-cache";
        expires -1;
        etag off;
        root /data/pentaq-weui-wap/dist;
        try_files $uri $uri/ /index.html;
    }

    location @wordpress {
        root /data/var/www/trunk/app/news;
        try_files $uri $uri/ /index.php?$args;
    }

nginx 当出现502状态时访问备用服务

先启动备用服务,再停主服务,然后更新主服务代码,最后启动主服务关闭备用服务。

达成服务无缝更新。

##nginx

    location / {
        error_page 502 = @backup;
        proxy_pass http://127.0.0.1:4000;
        proxy_redirect off;
        proxy_set_header X-Forwarded-For             $proxy_add_x_forwarded_for; 
    }
    location @backup {
        proxy_pass http://127.0.0.1:5000;
        proxy_redirect off;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

gitlab的相关信息

gitlab打包了nginx, redis, postgresql, sidekiq 和 unicorn 服务。
也因此在安装gitlab的机器上你不能再独立安装nginx,你可以直接使用gitlab提供的nginx。


相关配置文件Location
/var/opt/gitlab


启动、重启命令gitlab-ctl start gitlab-ctl stop gitlab-ctl restart
更多信息gitlab-ctl status gitlab-ctl help


只重启nginxsudo gitlab-ctl restart nginx