<p>昨天发的那个版本不够优雅,现在这个版本应该是<strong>终版</strong>了,个人觉得非常NICE <img src="https://linux.do/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p><br><h2><a name="p-1511962-h-1" class="anchor" href="#p-1511962-h-1"></a>先赞后看,养成习惯</h2><br><p>上图:<br><br>Worker网页中:<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/3/f36cfbb7c6c42b0e83970c5080e8b3404789bb14.png" data-download-href="https://linux.do/uploads/default/f36cfbb7c6c42b0e83970c5080e8b3404789bb14" title="image"><img src="https://linux.do/uploads/default/optimized/3X/f/3/f36cfbb7c6c42b0e83970c5080e8b3404789bb14_2_690x289.png" alt="image" data-base62-sha1="yJrwim8LvoZsWVTLweqo2a75QnG" width="690" height="289" srcset="https://linux.do/uploads/default/optimized/3X/f/3/f36cfbb7c6c42b0e83970c5080e8b3404789bb14_2_690x289.png, https://linux.do/uploads/default/optimized/3X/f/3/f36cfbb7c6c42b0e83970c5080e8b3404789bb14_2_1035x433.png 1.5x, https://linux.do/uploads/default/optimized/3X/f/3/f36cfbb7c6c42b0e83970c5080e8b3404789bb14_2_1380x578.png 2x" data-dominant-color="F0F2F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2275×956 50.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/3/8/381ce69950deac893421919a4d3b1f3f188db819.png" data-download-href="https://linux.do/uploads/default/381ce69950deac893421919a4d3b1f3f188db819" title="image"><img src="https://linux.do/uploads/default/optimized/3X/3/8/381ce69950deac893421919a4d3b1f3f188db819_2_690x354.png" alt="image" data-base62-sha1="80oENfED9DDlNzRty81RqKtZBXj" width="690" height="354" srcset="https://linux.do/uploads/default/optimized/3X/3/8/381ce69950deac893421919a4d3b1f3f188db819_2_690x354.png, https://linux.do/uploads/default/optimized/3X/3/8/381ce69950deac893421919a4d3b1f3f188db819_2_1035x531.png 1.5x, https://linux.do/uploads/default/optimized/3X/3/8/381ce69950deac893421919a4d3b1f3f188db819_2_1380x708.png 2x" data-dominant-color="F0F1F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2430×1248 151 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p>电报中:<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/c/2/c2e142f8b47d7d0bc5f1ba410223247e8e36ec5f.png" data-download-href="https://linux.do/uploads/default/c2e142f8b47d7d0bc5f1ba410223247e8e36ec5f" title="image"><img src="https://linux.do/uploads/default/original/3X/c/2/c2e142f8b47d7d0bc5f1ba410223247e8e36ec5f.png" alt="image" data-base62-sha1="rNZfv8oy0dwGvgXrZlPeNk7XtDx" width="690" height="154" data-dominant-color="253240"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">703×157 6.46 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p>serv00面板:<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/c/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd.png" data-download-href="https://linux.do/uploads/default/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd" title="image"><img src="https://linux.do/uploads/default/optimized/3X/f/c/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd_2_690x205.png" alt="image" data-base62-sha1="A3UrIRTC0WqzFKkoWBUTqqLqxuR" width="690" height="205" srcset="https://linux.do/uploads/default/optimized/3X/f/c/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd_2_690x205.png, https://linux.do/uploads/default/optimized/3X/f/c/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd_2_1035x307.png 1.5x, https://linux.do/uploads/default/optimized/3X/f/c/fcbf6c9cd82fd6b4e9ff45e7c81c44c795ec44dd_2_1380x410.png 2x" data-dominant-color="FBFBFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2656×791 74.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h1><a name="p-1511962-h-1cloudflareworker-2" class="anchor" href="#p-1511962-h-1cloudflareworker-2"></a>1.在cloudflare创建worker</h1><br><p>登录以下网址:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://www.cloudflare.com"><br> <header class="source"><br> <img src="https://linux.do/uploads/default/original/2X/6/6306931ef78f06dfd75847eb0b7e513657e7ec29.png" class="site-icon" data-dominant-color="F58827" width="96" height="96"><br><br> <a href="https://www.cloudflare.com" target="_blank" rel="noopener nofollow ugc">cloudflare.com</a><br> </header><br><br> <article class="onebox-body"><br> <div class="aspect-image" style="--aspect-ratio:690/361;"><img src="https://linux.do/uploads/default/optimized/2X/c/c8872aee011eded9169f69dd6fa419751e6a37ce_2_690x361.jpeg" class="thumbnail" data-dominant-color="FA9C3E" width="690" height="361"></div><br><br><h3><a href="https://www.cloudflare.com" target="_blank" rel="noopener nofollow ugc">Connect, Protect and Build Everywhere</a></h3><br><br> <p>Make employees, applications and networks faster and more secure everywhere, while reducing complexity and cost.</p><br><br><br> </article><br><br> <div class="onebox-metadata"><br> <br> <br> </div><br><br> <div style="clear: both"></div><br></aside><br><br><h2><a name="p-1511962-worker-3" class="anchor" href="#p-1511962-worker-3"></a>创建worker</h2><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/6/4/64b89066c602f035ddd19546b0ec9d643f24c86b.png" data-download-href="https://linux.do/uploads/default/64b89066c602f035ddd19546b0ec9d643f24c86b" title="image"><img src="https://linux.do/uploads/default/optimized/3X/6/4/64b89066c602f035ddd19546b0ec9d643f24c86b_2_689x339.png" alt="image" data-base62-sha1="en1aLQtcY6pvIqYfNw7oesvJpHl" width="689" height="339" srcset="https://linux.do/uploads/default/optimized/3X/6/4/64b89066c602f035ddd19546b0ec9d643f24c86b_2_689x339.png, https://linux.do/uploads/default/optimized/3X/6/4/64b89066c602f035ddd19546b0ec9d643f24c86b_2_1033x508.png 1.5x, https://linux.do/uploads/default/optimized/3X/6/4/64b89066c602f035ddd19546b0ec9d643f24c86b_2_1378x678.png 2x" data-dominant-color="F9FAFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2215×1089 178 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/e/f/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87.png" data-download-href="https://linux.do/uploads/default/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87" title="image"><img src="https://linux.do/uploads/default/optimized/3X/e/f/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87_2_690x271.png" alt="image" data-base62-sha1="y6S8PlbENUMbUbtRW0IOf6rfRHh" width="690" height="271" srcset="https://linux.do/uploads/default/optimized/3X/e/f/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87_2_690x271.png, https://linux.do/uploads/default/optimized/3X/e/f/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87_2_1035x406.png 1.5x, https://linux.do/uploads/default/optimized/3X/e/f/ef10d0c1d07c1854f7ff0dab2ae8a7dc314d2a87_2_1380x542.png 2x" data-dominant-color="F0F7F9"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2305×907 102 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/b/fbe2c6700f3881fd6247798d4af3a5fc572f1a60.png" data-download-href="https://linux.do/uploads/default/fbe2c6700f3881fd6247798d4af3a5fc572f1a60" title="image"><img src="https://linux.do/uploads/default/optimized/3X/f/b/fbe2c6700f3881fd6247798d4af3a5fc572f1a60_2_690x379.png" alt="image" data-base62-sha1="zWhHVQ53UPOaQnO1Eyp4VLE1LfG" width="690" height="379" srcset="https://linux.do/uploads/default/optimized/3X/f/b/fbe2c6700f3881fd6247798d4af3a5fc572f1a60_2_690x379.png, https://linux.do/uploads/default/optimized/3X/f/b/fbe2c6700f3881fd6247798d4af3a5fc572f1a60_2_1035x568.png 1.5x, https://linux.do/uploads/default/optimized/3X/f/b/fbe2c6700f3881fd6247798d4af3a5fc572f1a60_2_1380x758.png 2x" data-dominant-color="F4F4F5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2381×1310 141 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/b/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3.png" data-download-href="https://linux.do/uploads/default/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3" title="image"><img src="https://linux.do/uploads/default/optimized/3X/f/b/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3_2_690x77.png" alt="image" data-base62-sha1="zXctAFS1gnN9Pt8IJzqogqekQcb" width="690" height="77" srcset="https://linux.do/uploads/default/optimized/3X/f/b/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3_2_690x77.png, https://linux.do/uploads/default/optimized/3X/f/b/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3_2_1035x115.png 1.5x, https://linux.do/uploads/default/optimized/3X/f/b/fbfd4590bf18ab5ce0107aa0f998a9a659b2e0c3_2_1380x154.png 2x" data-dominant-color="FBFCFD"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2596×290 22 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h2><a name="p-1511962-worker-4" class="anchor" href="#p-1511962-worker-4"></a>将下面代码复制粘贴进worker</h2><br><pre><code class="lang-auto">addEventListener('fetch', event => {<br> event.respondWith(handleRequest(event.request))<br>})<br><br>addEventListener('scheduled', event => {<br> event.waitUntil(handleScheduled(event.scheduledTime))<br>})<br><br>async function handleRequest(request) {<br> const url = new URL(request.url)<br> <br> if (url.pathname === '/login' && request.method === 'POST') {<br> const formData = await request.formData()<br> const password = formData.get('password')<br> <br> if (password === PASSWORD) {<br> const response = new Response(JSON.stringify({ success: true }), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> response.headers.set('Set-Cookie', `auth=${PASSWORD}; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=86400`)<br> return response<br> } else {<br> return new Response(JSON.stringify({ success: false }), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> }<br> } else if (url.pathname === '/run' && request.method === 'POST') {<br> if (!isAuthenticated(request)) {<br> return new Response('Unauthorized', { status: 401 })<br> }<br> <br> await handleScheduled(new Date().toISOString())<br> const results = await CRON_RESULTS.get('lastResults', 'json')<br> return new Response(JSON.stringify(results), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> } else if (url.pathname === '/results' && request.method === 'GET') {<br> if (!isAuthenticated(request)) {<br> return new Response(JSON.stringify({ authenticated: false }), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> }<br> const results = await CRON_RESULTS.get('lastResults', 'json')<br> return new Response(JSON.stringify({ authenticated: true, results: results || [] }), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> } else if (url.pathname === '/check-auth' && request.method === 'GET') {<br> return new Response(JSON.stringify({ authenticated: isAuthenticated(request) }), {<br> headers: { 'Content-Type': 'application/json' }<br> })<br> } else {<br> // 显示登录页面或结果页面的 HTML<br> return new Response(getHtmlContent(), {<br> headers: { 'Content-Type': 'text/html' },<br> })<br> }<br>}<br><br>function isAuthenticated(request) {<br> const cookies = request.headers.get('Cookie')<br> if (cookies) {<br> const authCookie = cookies.split(';').find(c => c.trim().startsWith('auth='))<br> if (authCookie) {<br> const authValue = authCookie.split('=')[1]<br> return authValue === PASSWORD<br> }<br> }<br> return false<br>}<br><br>function getHtmlContent() {<br> return `<br> <!DOCTYPE html><br> <html lang="en"><br> <head><br> <meta charset="UTF-8"><br> <meta name="viewport" content="width=device-width, initial-scale=1.0"><br> <title>Worker Control Panel</title><br> <style><br> body {<br> font-family: Arial, sans-serif;<br> display: flex;<br> justify-content: center;<br> align-items: center;<br> min-height: 100vh;<br> margin: 0;<br> background-color: #f0f0f0;<br> }<br> .container {<br> text-align: center;<br> padding: 20px;<br> background-color: white;<br> border-radius: 8px;<br> box-shadow: 0 2px 4px rgba(0,0,0,0.1);<br> max-width: 800px;<br> width: 100%;<br> }<br> input, button {<br> margin: 10px 0;<br> padding: 10px;<br> width: 200px;<br> border-radius: 4px;<br> border: 1px solid #ddd;<br> }<br> button {<br> background-color: #4CAF50;<br> border: none;<br> color: white;<br> cursor: pointer;<br> }<br> #status {<br> margin-top: 20px;<br> font-weight: bold;<br> }<br> table {<br> width: 100%;<br> border-collapse: collapse;<br> margin-top: 20px;<br> }<br> th, td {<br> border: 1px solid #ddd;<br> padding: 8px;<br> text-align: left;<br> }<br> th {<br> background-color: #f2f2f2;<br> }<br> #loginForm, #dashboard {<br> display: none;<br> }<br> </style><br> </head><br> <body><br> <div class="container"><br> <h1>Worker Control Panel</h1><br> <div id="loginForm"><br> <input type="password" id="password" placeholder="Enter password"><br> <button onclick="login()">Login</button><br> </div><br> <div id="dashboard"><br> <button onclick="runScript()">Run Script</button><br> <div id="status"></div><br> <table id="resultsTable"><br> <thead><br> <tr><br> <th>Account</th><br> <th>Type</th><br> <th>Status</th><br> <th>Message</th><br> <th>Last Run</th><br> </tr><br> </thead><br> <tbody></tbody><br> </table><br> </div><br> </div><br> <script><br> let password = '';<br><br> function showLoginForm() {<br> document.getElementById('loginForm').style.display = 'block';<br> document.getElementById('dashboard').style.display = 'none';<br> }<br><br> function showDashboard() {<br> document.getElementById('loginForm').style.display = 'none';<br> document.getElementById('dashboard').style.display = 'block';<br> fetchResults();<br> }<br><br> async function checkAuth() {<br> const response = await fetch('/check-auth');<br> const data = await response.json();<br> if (data.authenticated) {<br> showDashboard();<br> } else {<br> showLoginForm();<br> }<br> }<br><br> async function login() {<br> password = document.getElementById('password').value;<br> const formData = new FormData();<br> formData.append('password', password);<br> const response = await fetch('/login', { <br> method: 'POST',<br> body: formData<br> });<br> const result = await response.json();<br> if (result.success) {<br> showDashboard();<br> } else {<br> alert('Incorrect password');<br> }<br> }<br><br> async function runScript() {<br> const statusDiv = document.getElementById('status');<br> statusDiv.textContent = 'Executing script...';<br> try {<br> const response = await fetch('/run', { method: 'POST' });<br> if (response.ok) {<br> const results = await response.json();<br> displayResults(results);<br> statusDiv.textContent = 'Script executed successfully!';<br> } else if (response.status === 401) {<br> statusDiv.textContent = 'Unauthorized. Please login again.';<br> showLoginForm();<br> } else {<br> statusDiv.textContent = 'Error executing script.';<br> }<br> } catch (error) {<br> statusDiv.textContent = 'Error: ' + error.message;<br> }<br> }<br><br> async function fetchResults() {<br> try {<br> const response = await fetch('/results');<br> if (response.ok) {<br> const data = await response.json();<br> if (data.authenticated) {<br> displayResults(data.results);<br> } else {<br> showLoginForm();<br> }<br> } else {<br> console.error('Failed to fetch results');<br> showLoginForm();<br> }<br> } catch (error) {<br> console.error('Error fetching results:', error);<br> showLoginForm();<br> }<br> }<br><br> function displayResults(results) {<br> const tbody = document.querySelector('#resultsTable tbody');<br> tbody.innerHTML = '';<br> results.forEach(result => {<br> result.cronResults.forEach((cronResult, index) => {<br> const row = tbody.insertRow();<br> if (index === 0) {<br> row.insertCell(0).textContent = result.username;<br> row.insertCell(1).textContent = result.type;<br> } else {<br> row.insertCell(0).textContent = '';<br> row.insertCell(1).textContent = '';<br> }<br> row.insertCell(2).textContent = cronResult.success ? 'Success' : 'Failed';<br> row.insertCell(3).textContent = cronResult.message;<br> row.insertCell(4).textContent = new Date(result.lastRun).toLocaleString();<br> });<br> });<br> }<br><br> // 页面加载时检查认证状态<br> document.addEventListener('DOMContentLoaded', checkAuth);<br> </script><br> </body><br> </html><br> `;<br>}<br><br>async function handleScheduled(scheduledTime) {<br> const accountsData = JSON.parse(ACCOUNTS_JSON);<br> const accounts = accountsData.accounts;<br> <br> let results = [];<br> for (const account of accounts) {<br> const result = await loginAccount(account);<br> results.push(result);<br> await delay(Math.floor(Math.random() * 8000) + 1000);<br> }<br><br> // 保存结果到 KV 存储<br> await CRON_RESULTS.put('lastResults', JSON.stringify(results));<br>}<br><br>function generateRandomUserAgent() {<br> const browsers = ['Chrome', 'Firefox', 'Safari', 'Edge', 'Opera'];<br> const browser = browsers[Math.floor(Math.random() * browsers.length)];<br> const version = Math.floor(Math.random() * 100) + 1;<br> const os = ['Windows NT 10.0', 'Macintosh', 'X11'];<br> const selectedOS = os[Math.floor(Math.random() * os.length)];<br> const osVersion = selectedOS === 'X11' ? 'Linux x86_64' : selectedOS === 'Macintosh' ? 'Intel Mac OS X 10_15_7' : 'Win64; x64';<br><br> return `Mozilla/5.0 (${selectedOS}; ${osVersion}) AppleWebKit/537.36 (KHTML, like Gecko) ${browser}/${version}.0.0.0 Safari/537.36`;<br>}<br><br>async function loginAccount(account) {<br> const { username, password, panelnum, type, cronCommands } = account<br> let baseUrl = type === 'ct8' <br> ? 'https://panel.ct8.pl' <br> : `https://panel${panelnum}.serv00.com`<br> let loginUrl = `${baseUrl}/login/?next=/cron/`<br><br> const userAgent = generateRandomUserAgent();<br><br> try {<br> const response = await fetch(loginUrl, {<br> method: 'GET',<br> headers: {<br> 'User-Agent': userAgent,<br> },<br> })<br><br> const pageContent = await response.text()<br> const csrfMatch = pageContent.match(/name="csrfmiddlewaretoken" value="([^"]*)"/)<br> const csrfToken = csrfMatch ? csrfMatch[1] : null<br><br> if (!csrfToken) {<br> throw new Error('CSRF token not found')<br> }<br><br> const initialCookies = response.headers.get('set-cookie') || ''<br><br> const formData = new URLSearchParams({<br> 'username': username,<br> 'password': password,<br> 'csrfmiddlewaretoken': csrfToken,<br> 'next': '/cron/'<br> })<br><br> const loginResponse = await fetch(loginUrl, {<br> method: 'POST',<br> headers: {<br> 'Content-Type': 'application/x-www-form-urlencoded',<br> 'Referer': loginUrl,<br> 'User-Agent': userAgent,<br> 'Cookie': initialCookies,<br> },<br> body: formData.toString(),<br> redirect: 'manual'<br> })<br><br> if (loginResponse.status === 302 && loginResponse.headers.get('location') === '/cron/') {<br> const loginCookies = loginResponse.headers.get('set-cookie') || ''<br> const allCookies = combineCookies(initialCookies, loginCookies)<br><br> // 访问 cron 列表页面<br> const cronListUrl = `${baseUrl}/cron/`<br> const cronListResponse = await fetch(cronListUrl, {<br> headers: {<br> 'Cookie': allCookies,<br> 'User-Agent': userAgent,<br> }<br> })<br> const cronListContent = await cronListResponse.text()<br><br> console.log(`Cron list URL: ${cronListUrl}`)<br> console.log(`Cron list response status: ${cronListResponse.status}`)<br> console.log(`Cron list content (first 1000 chars): ${cronListContent.substring(0, 1000)}`)<br><br> let cronResults = [];<br> for (const cronCommand of cronCommands) {<br> if (!cronListContent.includes(cronCommand)) {<br> // 访问添加 cron 任务页面<br> const addCronUrl = `${baseUrl}/cron/add`<br> const addCronPageResponse = await fetch(addCronUrl, {<br> headers: {<br> 'Cookie': allCookies,<br> 'User-Agent': userAgent,<br> 'Referer': cronListUrl,<br> }<br> })<br> const addCronPageContent = await addCronPageResponse.text()<br><br> console.log(`Add cron page URL: ${addCronUrl}`)<br> console.log(`Add cron page response status: ${addCronPageResponse.status}`)<br> console.log(`Add cron page content (first 1000 chars): ${addCronPageContent.substring(0, 1000)}`)<br><br> const newCsrfMatch = addCronPageContent.match(/name="csrfmiddlewaretoken" value="([^"]*)"/)<br> const newCsrfToken = newCsrfMatch ? newCsrfMatch[1] : null<br><br> if (!newCsrfToken) {<br> throw new Error('New CSRF token not found for adding cron task')<br> }<br><br> const formData = new URLSearchParams({<br> 'csrfmiddlewaretoken': newCsrfToken,<br> 'spec': 'manual',<br> 'minute_time_interval': 'on',<br> 'minute': '15',<br> 'hour_time_interval': 'each',<br> 'hour': '*',<br> 'day_time_interval': 'each',<br> 'day': '*',<br> 'month_time_interval': 'each',<br> 'month': '*',<br> 'dow_time_interval': 'each',<br> 'dow': '*',<br> 'command': cronCommand,<br> 'comment': 'Auto added cron job'<br> })<br><br> console.log('Form data being sent:', formData.toString())<br><br> const { success, response: addCronResponse, content: addCronResponseContent } = await addCronWithRetry(addCronUrl, {<br> method: 'POST',<br> headers: {<br> 'Content-Type': 'application/x-www-form-urlencoded',<br> 'Cookie': allCookies,<br> 'User-Agent': userAgent,<br> 'Referer': addCronUrl,<br> 'Origin': baseUrl,<br> 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',<br> 'Accept-Language': 'en-US,en;q=0.5',<br> 'Upgrade-Insecure-Requests': '1'<br> },<br> body: formData.toString(),<br> })<br><br> console.log('Full response content:', addCronResponseContent)<br><br> if (success) {<br> if (addCronResponseContent.includes('Cron job has been added') || addCronResponseContent.includes('Zadanie cron zostało dodane')) {<br> const message = `添加了新的 cron 任务:${cronCommand}`;<br> console.log(message);<br> await sendTelegramMessage(`账号 ${username} (${type}) ${message}`);<br> cronResults.push({ success: true, message });<br> } else {<br> // 如果响应中没有成功信息,再次检查cron列表<br> const checkCronListResponse = await fetch(cronListUrl, {<br> headers: {<br> 'Cookie': allCookies,<br> 'User-Agent': userAgent,<br> }<br> });<br> const checkCronListContent = await checkCronListResponse.text();<br> <br> if (checkCronListContent.includes(cronCommand)) {<br> const message = `确认添加了新的 cron 任务:${cronCommand}`;<br> console.log(message);<br> await sendTelegramMessage(`账号 ${username} (${type}) ${message}`);<br> cronResults.push({ success: true, message });<br> } else {<br> const message = `尝试添加 cron 任务:${cronCommand},但在列表中未找到。可能添加失败。`;<br> console.error(message);<br> cronResults.push({ success: false, message });<br> }<br> }<br> } else {<br> const message = `添加 cron 任务失败:${cronCommand}`;<br> console.error(message);<br> cronResults.push({ success: false, message });<br> }<br> } else {<br> const message = `cron 任务已存在:${cronCommand}`;<br> console.log(message);<br> cronResults.push({ success: true, message });<br> }<br> }<br> return { username, type, cronResults, lastRun: new Date().toISOString() };<br> } else {<br> const message = `登录失败,未知原因。请检查账号和密码是否正确。`;<br> console.error(message);<br> return { username, type, cronResults: [{ success: false, message }], lastRun: new Date().toISOString() };<br> }<br> } catch (error) {<br> const message = `登录或添加 cron 任务时出现错误: ${error.message}`;<br> console.error(message);<br> return { username, type, cronResults: [{ success: false, message }], lastRun: new Date().toISOString() };<br> }<br>}<br><br>async function addCronWithRetry(url, options, maxRetries = 3) {<br> for (let i = 0; i < maxRetries; i++) {<br> try {<br> const response = await fetch(url, options);<br> const responseContent = await response.text();<br> console.log(`Attempt ${i + 1} response status:`, response.status);<br> console.log(`Attempt ${i + 1} response content (first 1000 chars):`, responseContent.substring(0, 1000));<br> <br> if (response.status === 200 || response.status === 302 || responseContent.includes('Cron job has been added') || responseContent.includes('Zadanie cron zostało dodane')) {<br> return { success: true, response, content: responseContent };<br> }<br> } catch (error) {<br> console.error(`Attempt ${i + 1} failed:`, error);<br> }<br> await delay(2000); // Wait 2 seconds before retrying<br> }<br> return { success: false };<br>}<br><br>function combineCookies(cookies1, cookies2) {<br> const cookieMap = new Map()<br> <br> const parseCookies = (cookieString) => {<br> cookieString.split(',').forEach(cookie => {<br> const [fullCookie] = cookie.trim().split(';')<br> const [name, value] = fullCookie.split('=')<br> if (name && value) {<br> cookieMap.set(name.trim(), value.trim())<br> }<br> })<br> }<br><br> parseCookies(cookies1)<br> parseCookies(cookies2)<br><br> return Array.from(cookieMap.entries()).map(([name, value]) => `${name}=${value}`).join('; ')<br>}<br><br>async function sendTelegramMessage(message) {<br> const telegramConfig = JSON.parse(TELEGRAM_JSON)<br> const { telegramBotToken, telegramBotUserId } = telegramConfig<br> const url = `https://api.telegram.org/bot${telegramBotToken}/sendMessage`<br> <br> try {<br> await fetch(url, {<br> method: 'POST',<br> headers: { 'Content-Type': 'application/json' },<br> body: JSON.stringify({<br> chat_id: telegramBotUserId,<br> text: message<br> })<br> })<br> } catch (error) {<br> console.error('Error sending Telegram message:', error)<br> }<br>}<br><br>function delay(ms) {<br> return new Promise(resolve => setTimeout(resolve, ms))<br>}<br></code></pre><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/9/c/9c613f8efa936c99752be55e3b3012946eef97af.png" data-download-href="https://linux.do/uploads/default/9c613f8efa936c99752be55e3b3012946eef97af" title="image"><img src="https://linux.do/uploads/default/optimized/3X/9/c/9c613f8efa936c99752be55e3b3012946eef97af_2_690x199.png" alt="image" data-base62-sha1="mjoQ0zEaPlcGMMlTUUsyDN5yRgr" width="690" height="199" srcset="https://linux.do/uploads/default/optimized/3X/9/c/9c613f8efa936c99752be55e3b3012946eef97af_2_690x199.png, https://linux.do/uploads/default/optimized/3X/9/c/9c613f8efa936c99752be55e3b3012946eef97af_2_1035x298.png 1.5x, https://linux.do/uploads/default/optimized/3X/9/c/9c613f8efa936c99752be55e3b3012946eef97af_2_1380x398.png 2x" data-dominant-color="F6F7F7"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2903×840 152 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h1><a name="p-1511962-h-2-5" class="anchor" href="#p-1511962-h-2-5"></a>2.创建变量</h1><br><p><code>ACCOUNTS_JSON</code></p><br><pre><code class="lang-auto">{<br> "accounts": [<br> {<br> "username": "user1",<br> "password": "password1",<br> "type": "ct8",<br> "cronCommands": [<br> "/usr/home/serv00name/domains",<br> "你的脚本"<br> ]<br> },<br> {<br> "username": "user2",<br> "password": "password2",<br> "panelnum": "2",<br> "type": "serv00",<br> "cronCommands": [<br> "/usr/home/serv00name"<br> ]<br> },<br> {<br> "username": "user3",<br> "password": "password3",<br> "type": "ct8",<br> "cronCommands": [<br> "/usr/home/serv00name",<br> "你的脚本",<br> "python /usr/home/serv00name/domains/backup.py"<br> ]<br> }<br> ]<br>}<br></code></pre><br><p><strong><code>cronCommands</code>这部分是你想要添加的cron任务,可以是路径,也可以是程序运行的命令(一个引号内是完整的执行命令)</strong><br><br><strong>不提供解决<code>cronCommands</code>命令问题</strong><br><br>实在不会的可以参考这篇文章,不同程序封装保活脚本类似,细节修改问一下站内OAI就能解决:</p><aside class="quote quote-modified" data-post="1" data-topic="166344"><br> <div class="title"><br> <div class="quote-controls"></div><br> <img loading="lazy" alt="" width="24" height="24" src="https://linux.do/user_avatar/linux.do/xjfkkk/48/12365_2.png" class="avatar"><br> <a href="https://linux.do/t/topic/166344">通过在serv00上搭建Alist复现在huggingface保活运行程序</a> <a class="badge-category__wrapper " href="/c/resource/14"><span data-category-id="14" style="--category-badge-color: #12A89D; --category-badge-text-color: #FFFFFF;" data-drop-close="true" class="badge-category " title="包括软件分享、开源仓库、视频课程、书籍等分享"><span class="badge-category__name">资源荟萃</span></span></a><br> </div><br> <blockquote><br> <a name="p-1267787-huggingfaceserv00-1" class="anchor" href="#p-1267787-huggingfaceserv00-1"></a>本文主要集中在huggingface保活,在serv00部署的所有服务都可以参考下面方式进行保活<br><br><br><a name="p-1267787-h-1-2" class="anchor" href="#p-1267787-h-1-2"></a>1.开放一个端口并开启应用权限<br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/c/fcb542d8db619163a6727a6d49e6dcbff30a35d4.jpeg" data-download-href="https://linux.do/uploads/default/fcb542d8db619163a6727a6d49e6dcbff30a35d4" title="image">[image]</a> <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/a/2/a2aaf32a1287e2292ecb1371aff272dd8c36e5b2.jpeg" data-download-href="https://linux.do/uploads/default/a2aaf32a1287e2292ecb1371aff272dd8c36e5b2" title="image">[image]</a> <br><a name="p-1267787-h-2serv00website-3" class="anchor" href="#p-1267787-h-2serv00website-3"></a>2.将域名托管到serv00并创建Website<br>域名托管不在这里叙述,可以看这部分,也可以使用CF进行托管 <br><br>创建Website <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/8/f806b69c9d0bb6a20f4c70ef353f661eb7a91dc5.png" data-download-href="https://linux.do/uploads/default/f806b69c9d0bb6a20f4c70ef353f661eb7a91dc5" title="image">[image]</a> <br><a name="p-1267787-h-3-mysql-4" class="anchor" href="#p-1267787-h-3-mysql-4"></a>3. 创建mysql数据库<br>记住你创建的数据库,等会需要用 <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/7/5/75d911cd75d7244b7a419ac317e4a7685111e602.png" data-download-href="https://linux.do/uploads/default/75d911cd75d7244b7a419ac317e4a7685111e602" title="image">[im…</a><br> </blockquote><br></aside><br><br><p><code>TELEGRAM_JSON</code></p><br><pre><code class="lang-auto">{<br> "telegramBotToken": "YOUR_BOT_TOKEN",<br> "telegramBotUserId": "YOUR_USER_ID"<br>}<br></code></pre><br><p>不知道变量如何设置可以看这里:</p><aside class="quote quote-modified" data-post="1" data-topic="161424"><br> <div class="title"><br> <div class="quote-controls"></div><br> <img loading="lazy" alt="" width="24" height="24" src="https://linux.do/user_avatar/linux.do/xjfkkk/48/12365_2.png" class="avatar"><br> <a href="https://linux.do/t/topic/161424">在github上保活serv00和CT8并接入Tg、钉钉机器人通知(有封github号风险)</a> <a class="badge-category__wrapper " href="/c/resource/14"><span data-category-id="14" style="--category-badge-color: #12A89D; --category-badge-text-color: #FFFFFF;" data-drop-close="true" class="badge-category " title="包括软件分享、开源仓库、视频课程、书籍等分享"><span class="badge-category__name">资源荟萃</span></span></a><br> </div><br> <blockquote><br> 先上效果图: <br>github中: <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/a/7/a76184ea58cb3683e7bd1f1dbe92591cfe1dcaff.png" data-download-href="https://linux.do/uploads/default/a76184ea58cb3683e7bd1f1dbe92591cfe1dcaff" title="image">[image]</a> <br>telegram中: <br><a class="lightbox" href="https://linux.do/uploads/default/original/3X/d/b/db461ff6d80908c31ad573c933635ab1ba8fb02a.png" data-download-href="https://linux.do/uploads/default/db461ff6d80908c31ad573c933635ab1ba8fb02a" title="image">[image]</a> <br><a class="lightbox" href="https://linux.do/uploads/default/original/3X/3/d/3dc6d620b309700dd21b15fc50550c1e050b7ecc.png" data-download-href="https://linux.do/uploads/default/3dc6d620b309700dd21b15fc50550c1e050b7ecc" title="image">[image]</a> <br>钉钉中 <br><a class="lightbox" href="https://linux.do/uploads/default/original/3X/5/e/5e9b8b9dee89b9601c6e2a936516fe6c06abbd4f.png" data-download-href="https://linux.do/uploads/default/5e9b8b9dee89b9601c6e2a936516fe6c06abbd4f" title="image">[image]</a> <br>项目地址: <br><br><a name="p-1202005-h-1fork-1" class="anchor" href="#p-1202005-h-1fork-1"></a>1.fork该项目<br><br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/a/f/af069a262841586c8d3bc59a41adb20b6f88e722.png" data-download-href="https://linux.do/uploads/default/af069a262841586c8d3bc59a41adb20b6f88e722" title="image">[image]</a> <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/9/9/9928fda112b639b81f24eec344c43b56920a8449.png" data-download-href="https://linux.do/uploads/default/9928fda112b639b81f24eec344c43b56920a8449" title="image">[image]</a> <br><a name="p-1202005-h-2accounts_json-2" class="anchor" href="#p-1202005-h-2accounts_json-2"></a>2.创建ACCOUNTS_JSON变量并填入信息<br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/8/0/80ba5cbada46cd25a7d1619b0d047c9b9605e24d.png" data-download-href="https://linux.do/uploads/default/80ba5cbada46cd25a7d1619b0d047c9b9605e24d" title="image">[image]</a> <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/a/3/a352d1c8b275cf45054b415cec7abd6dc4ce1e3c.png" data-download-href="https://linux.do/uploads/default/a352d1c8b275cf45054b415cec7abd6dc4ce1e3c" title="image">[image]</a> <br>ACCOUNTS_JSON <br>[ <br> { "username": "serv00us…<br> </blockquote><br></aside><br><br><p><code>PASSWORD</code></p><br><pre><code class="lang-auto">你访问worker面板的密码<br></code></pre><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/6/6/66567038acd102d416f3e931f7fa46476cd660c0.png" data-download-href="https://linux.do/uploads/default/66567038acd102d416f3e931f7fa46476cd660c0" title="image"><img src="https://linux.do/uploads/default/optimized/3X/6/6/66567038acd102d416f3e931f7fa46476cd660c0_2_690x234.png" alt="image" data-base62-sha1="eBjTvDNl99sf3hMBDYK6v12JIfm" width="690" height="234" srcset="https://linux.do/uploads/default/optimized/3X/6/6/66567038acd102d416f3e931f7fa46476cd660c0_2_690x234.png, https://linux.do/uploads/default/optimized/3X/6/6/66567038acd102d416f3e931f7fa46476cd660c0_2_1035x351.png 1.5x, https://linux.do/uploads/default/optimized/3X/6/6/66567038acd102d416f3e931f7fa46476cd660c0_2_1380x468.png 2x" data-dominant-color="F6F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2413×819 32.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h1><a name="p-1511962-h-3cron-6" class="anchor" href="#p-1511962-h-3cron-6"></a>3.添加Cron</h1><br><p><strong>为了避免频繁登录执行脚本,建议各位佬友把时间填4-12h为宜</strong><br><br>有佬友想:这么长时间执行一次我进程被杀的该如何是好 <img src="https://linux.do/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"><br><br><strong>后续在worker面板中解惑</strong><br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/e/d/ed8bd78365e9b813cb05281e79a188688b5df1f9.png" data-download-href="https://linux.do/uploads/default/ed8bd78365e9b813cb05281e79a188688b5df1f9" title="image"><img src="https://linux.do/uploads/default/optimized/3X/e/d/ed8bd78365e9b813cb05281e79a188688b5df1f9_2_690x305.png" alt="image" data-base62-sha1="xTqLKWe7tJGBcAcE7sX75etqxyV" width="690" height="305" srcset="https://linux.do/uploads/default/optimized/3X/e/d/ed8bd78365e9b813cb05281e79a188688b5df1f9_2_690x305.png, https://linux.do/uploads/default/optimized/3X/e/d/ed8bd78365e9b813cb05281e79a188688b5df1f9_2_1035x457.png 1.5x, https://linux.do/uploads/default/optimized/3X/e/d/ed8bd78365e9b813cb05281e79a188688b5df1f9_2_1380x610.png 2x" data-dominant-color="F7F8FB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2361×1047 163 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h1><a name="p-1511962-h-4kv-7" class="anchor" href="#p-1511962-h-4kv-7"></a>4.创建一个KV变量</h1><br><p>创建一个名为<code>CRON_RESULTS</code>的KV变量<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/4/1/4112f2ee40b17dead32f850960b5798470bbf3fd.png" data-download-href="https://linux.do/uploads/default/4112f2ee40b17dead32f850960b5798470bbf3fd" title="image"><img src="https://linux.do/uploads/default/optimized/3X/4/1/4112f2ee40b17dead32f850960b5798470bbf3fd_2_690x368.png" alt="image" data-base62-sha1="9hFDhdRVz5DuJdiTwrO9Swj7OWN" width="690" height="368" srcset="https://linux.do/uploads/default/optimized/3X/4/1/4112f2ee40b17dead32f850960b5798470bbf3fd_2_690x368.png, https://linux.do/uploads/default/optimized/3X/4/1/4112f2ee40b17dead32f850960b5798470bbf3fd_2_1035x552.png 1.5x, https://linux.do/uploads/default/optimized/3X/4/1/4112f2ee40b17dead32f850960b5798470bbf3fd_2_1380x736.png 2x" data-dominant-color="F8F8F9"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2193×1171 148 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/f/b/fbade23afb9eebea9ac3ce530405907e715d9e01.png" data-download-href="https://linux.do/uploads/default/fbade23afb9eebea9ac3ce530405907e715d9e01" title="image"><img src="https://linux.do/uploads/default/optimized/3X/f/b/fbade23afb9eebea9ac3ce530405907e715d9e01_2_690x399.png" alt="image" data-base62-sha1="zUso89GSrF6b1JNrlZdLYxVj7Hz" width="690" height="399" srcset="https://linux.do/uploads/default/optimized/3X/f/b/fbade23afb9eebea9ac3ce530405907e715d9e01_2_690x399.png, https://linux.do/uploads/default/optimized/3X/f/b/fbade23afb9eebea9ac3ce530405907e715d9e01_2_1035x598.png 1.5x, https://linux.do/uploads/default/optimized/3X/f/b/fbade23afb9eebea9ac3ce530405907e715d9e01_2_1380x798.png 2x" data-dominant-color="F6F8FB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1625×941 55.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p>回到刚才创建的worker界面绑定KV</p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/b/4/b47a12aaa346289ba72f43695d62f6bec5fa0021.png" data-download-href="https://linux.do/uploads/default/b47a12aaa346289ba72f43695d62f6bec5fa0021" title="image"><img src="https://linux.do/uploads/default/optimized/3X/b/4/b47a12aaa346289ba72f43695d62f6bec5fa0021_2_690x238.png" alt="image" data-base62-sha1="pKzu3b16ghrfZfJ7lDWxhnuXfB7" width="690" height="238" srcset="https://linux.do/uploads/default/optimized/3X/b/4/b47a12aaa346289ba72f43695d62f6bec5fa0021_2_690x238.png, https://linux.do/uploads/default/optimized/3X/b/4/b47a12aaa346289ba72f43695d62f6bec5fa0021_2_1035x357.png 1.5x, https://linux.do/uploads/default/optimized/3X/b/4/b47a12aaa346289ba72f43695d62f6bec5fa0021_2_1380x476.png 2x" data-dominant-color="F9FAFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2451×847 110 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><h1><a name="p-1511962-h-5-8" class="anchor" href="#p-1511962-h-5-8"></a>5.绑定自定义域名</h1><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/6/2/62e895905f8e425f3732871df38b9f0983e7ab4b.png" data-download-href="https://linux.do/uploads/default/62e895905f8e425f3732871df38b9f0983e7ab4b" title="image"><img src="https://linux.do/uploads/default/optimized/3X/6/2/62e895905f8e425f3732871df38b9f0983e7ab4b_2_690x267.png" alt="image" data-base62-sha1="e6Z6igSjLuiSTtSQIgdptXGfeTV" width="690" height="267" srcset="https://linux.do/uploads/default/optimized/3X/6/2/62e895905f8e425f3732871df38b9f0983e7ab4b_2_690x267.png, https://linux.do/uploads/default/optimized/3X/6/2/62e895905f8e425f3732871df38b9f0983e7ab4b_2_1035x400.png 1.5x, https://linux.do/uploads/default/optimized/3X/6/2/62e895905f8e425f3732871df38b9f0983e7ab4b_2_1380x534.png 2x" data-dominant-color="F9F7F9"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2255×875 70.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><strong>现在已经大功告成了</strong></p><br><p>访问你的worker网站并输入密码<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/9/e/9e4b29169a7eb389270cf56327e442b346212b64.png" data-download-href="https://linux.do/uploads/default/9e4b29169a7eb389270cf56327e442b346212b64" title="image"><img src="https://linux.do/uploads/default/optimized/3X/9/e/9e4b29169a7eb389270cf56327e442b346212b64_2_690x256.png" alt="image" data-base62-sha1="mAktcnqNIrpPYFgAH6Q6qEbV4J6" width="690" height="256" srcset="https://linux.do/uploads/default/optimized/3X/9/e/9e4b29169a7eb389270cf56327e442b346212b64_2_690x256.png, https://linux.do/uploads/default/optimized/3X/9/e/9e4b29169a7eb389270cf56327e442b346212b64_2_1035x384.png 1.5x, https://linux.do/uploads/default/optimized/3X/9/e/9e4b29169a7eb389270cf56327e442b346212b64_2_1380x512.png 2x" data-dominant-color="EFF1EF"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2183×810 19.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p>点击运行按钮jiao’b脚本就开始启动了<br><br><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/8/4/84df2c0c2b8f0f89074df477070ff4cbadc43d31.png" data-download-href="https://linux.do/uploads/default/84df2c0c2b8f0f89074df477070ff4cbadc43d31" title="image"><img src="https://linux.do/uploads/default/optimized/3X/8/4/84df2c0c2b8f0f89074df477070ff4cbadc43d31_2_690x180.png" alt="image" data-base62-sha1="iXraxBTLy8i0tekYLozllMWqOEF" width="690" height="180" srcset="https://linux.do/uploads/default/optimized/3X/8/4/84df2c0c2b8f0f89074df477070ff4cbadc43d31_2_690x180.png, https://linux.do/uploads/default/optimized/3X/8/4/84df2c0c2b8f0f89074df477070ff4cbadc43d31_2_1035x270.png 1.5x, https://linux.do/uploads/default/optimized/3X/8/4/84df2c0c2b8f0f89074df477070ff4cbadc43d31_2_1380x360.png 2x" data-dominant-color="F0F2F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1834×479 14 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p><div class="lightbox-wrapper"><a class="lightbox" href="https://linux.do/uploads/default/original/3X/0/c/0c8e9767574460570a894b5c88b02365fa581a26.png" data-download-href="https://linux.do/uploads/default/0c8e9767574460570a894b5c88b02365fa581a26" title="image"><img src="https://linux.do/uploads/default/optimized/3X/0/c/0c8e9767574460570a894b5c88b02365fa581a26_2_690x387.png" alt="image" data-base62-sha1="1N5ehu47YaucaGvwEVJDsiDFL02" width="690" height="387" srcset="https://linux.do/uploads/default/optimized/3X/0/c/0c8e9767574460570a894b5c88b02365fa581a26_2_690x387.png, https://linux.do/uploads/default/optimized/3X/0/c/0c8e9767574460570a894b5c88b02365fa581a26_2_1035x580.png 1.5x, https://linux.do/uploads/default/optimized/3X/0/c/0c8e9767574460570a894b5c88b02365fa581a26_2_1380x774.png 2x" data-dominant-color="F0F1F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2378×1335 154 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p><br><p>这个面板会记录你最后一次执行的命令结果,包括你手动执行或者是设置的定时Cron。</p><br><p>当你部署在serv00的网站不能访问时,通过访问worker,点击一下运行脚本就能马上执行任务了,避免了频繁的使用cron启动脚本登录网站执行命令 <img src="https://linux.do/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p><br><p>电报只有当cron被干掉重新建立时才会通知(运行就消息推送会消息爆炸),这个可视化面板会记录输出的最后一次运行状态算是弥补了这部分</p><br><h3><a name="p-1511962-serv00ct8-9" class="anchor" href="#p-1511962-serv00ct8-9"></a>保活serv00/CT8账号:</h3><br><aside class="quote quote-modified" data-post="1" data-topic="180293"><br> <div class="title"><br> <div class="quote-controls"></div><br> <img loading="lazy" alt="" width="24" height="24" src="https://linux.do/user_avatar/linux.do/xjfkkk/48/12365_2.png" class="avatar"><br> <a href="https://linux.do/t/topic/180293">报:可以用cloudflare worker保活serv00和CT8(接入了电报通知)</a> <a class="badge-category__wrapper " href="/c/resource/14"><span data-category-id="14" style="--category-badge-color: #12A89D; --category-badge-text-color: #FFFFFF;" data-drop-close="true" class="badge-category " title="包括软件分享、开源仓库、视频课程、书籍等分享"><span class="badge-category__name">资源荟萃</span></span></a><br> </div><br> <blockquote><br> 之前部署的github保活会封账号,建议停用。昨天我在huggingface弄了保活脚本存在不稳定性,且需要反代telegram并保活,实在是繁琐。 <br>现在在cloudflare worker中直接一个代码就解决了,然后在变量加入一个cron就行了。这个应该是最简单最稳定的了,你的serv00账号封了他应该都还活着 <img width="20" height="20" src="https://linux.do/images/emoji/apple/wink.png?v=12" title="wink" alt="wink" class="emoji"> <br><a name="p-1485338-h-1" class="anchor" href="#p-1485338-h-1"></a>先赞后看,养成习惯<br>上图: <br>电报中: <br> <a class="lightbox" href="https://linux.do/uploads/default/original/3X/d/8/d85ca8988639c60af914e3f44b8203b63fc7ea2f.png" data-download-href="https://linux.do/uploads/default/d85ca8988639c60af914e3f44b8203b63fc7ea2f" title="image">[image]</a> <br>se…<br> </blockquote><br></aside><br> |
|