我在heroku上托管了一个不和谐的聊天机器人,突然它脱机了。我是在Heroku上托管的新手,所以我不太了解,但是,我尝试了一些简单的事情,例如再次部署一个分支(与github即时连接),但这是行不通的。
编辑: 这是日志:
在我单击打开应用程序之前:
2018-07-23T16:54:27.265702 + 00:00 app [worker.1]:在Function.Module._load(module.js:497:3)
2018-07-23T16:54:27.265704 + 00:00 app [worker.1]:位于Function.Module.runMain(module.js:693:10)
2018-07-23T16:54:27.265705 + 00:00 app [worker.1]:启动时(bootstrap_node.js:191:16)
2018-07-23T16:54:27.265707 + 00:00 app [worker.1]:在bootstrap_node.js:612:3
2018-07-23T16:54:27.327613 + 00:00 heroku [worker.1]:状态从向上更改为崩溃
2018-07-23T16:54:27.310511 + 00:00 heroku [worker.1]:进程退出,状态为1
点击“打开应用”后:
2018-07-23T16:58:44.866697 + 00:00 heroku [router]:at =错误代码= H14 desc =“没有正在运行的Web进程” method = GET path =“ /” host = cratefield.herokuapp.com request_id = b32a5f7d-157e-45a5-805b-8c306140d020 fwd =“ 73.23.238.216” dyno = connect = service = status = 503字节= protocol = https
2018-07-23T16:58:45.502353 + 00:00 heroku [router]:at =错误代码= H14 desc =“没有正在运行的Web进程” method = GET path =“ / favicon.ico” host = cratefield。 herokuapp.com request_id = 19e6fc48-37ed-48db-87f9-759d704ddb3e fwd =“ 73.23.238.216” dyno = connect = service = status = 503 bytes = protocol = https
2018-07-23T16:58:45.552383 + 00:00 heroku [router]:at =错误代码= H14 desc =“没有正在运行的Web进程” method = GET path =“ / favicon.ico” host = cratefield。 herokuapp.com request_id = bba2456f-50bc-4dbb-bee2-50b36a8caef5 fwd =“ 73.23.238.216” dyno = connect = service = status = 503 bytes = protocol = https
2018-07-23T17:01:47.069331 + 00:00 heroku [router]:at =错误代码= H14 desc =“没有正在运行的Web进程” method = GET path =“ /” host = cratefield.herokuapp.com request_id = 9a098d43-bc46-403a-9ed3-5b701cd720ac fwd =“ 73.23.238.216” dyno = connect = service =状态= 503字节=协议= https
答案 0 :(得分:0)
机器人的问题是Heroku's free plan使您的应用程序在闲置30分钟后进入休眠状态。解决方案是选择一个付费计划,以确保您的机器人始终保持活动状态。
答案 1 :(得分:0)
之所以发生这种情况,是因为您使用的是web
dyno:如果应用程序在一个网站上的服务时间不超过1小时,则该dyno会处于睡眠状态。
解决方案是将web
dyno切换为worker
dyno:此类型不提供网站服务(如果您运行Discord机器人,则不需要它)并且永远不会进入睡眠状态
进入您的Procfile
文件并将web
替换为worker
,它看起来应该像这样:
worker: npm start //this is the command you use to start your app.
如果您愿意,可以看看Heroku article about sleeping apps。
答案 2 :(得分:0)
我知道已经晚了一年,但是对于那些仍然遇到此问题的人,您每月可以限制550小时(约22天)来使用免费计划托管您的机器人(付费计划没有运行时间限制)
这可能是问题所在,您可以在heroku上查看通知以进行查找。
答案 3 :(得分:-1)
让机器人停止睡眠的一种更简单的方法是简单地使用import React, { Component } from 'react';
import { BrowserRouter as Router, Route,Switch, Redirect} from 'react-router-dom'
import logo from './logo.svg';
import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import Hello from './Hello.js';
import { Button, Row, Col, Container, Input, Label } from 'reactstrap';
import {
Collapse,
Navbar,
NavbarToggler,
NavbarBrand,
Nav,
NavItem,
NavLink,
UncontrolledDropdown,
DropdownToggle,
DropdownMenu,
DropdownItem } from 'reactstrap';
class App extends Component {
constructor(props){
super(props);
this.state = {
query1: '',
query2: '',
error: '',
epoch: null,
validation_accuracy: null,
isOpen: false,
email: '',
accuracy: ''
}
this.updateInput1 = this.updateInput1.bind(this);
this.updateInput2 = this.updateInput2.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.toggle = this.toggle.bind(this);
this.ticker = this.ticker.bind(this);
this.checkEpoch = this.checkEpoch.bind(this);
}
updateInput1(event){
this.setState({query1: event.target.value});
console.log(event.target.value);
}
updateInput2(event){
this.setState({query2: event.target.value});
console.log(event.target.value);
}
checkEpoch(e){
// while(this.state.epoch == null && this.state.epoch < 100){
fetch('http://localhost:4000/', {
method: 'GET',
headers: {
'Content-type': 'application/json',
},
})
.then(res => this.setState({epoch : res.json().epoch, accuracy: res.json().accuracy}))
.then(res => console.log(this.state.epoch))
.then(res => console.log(this.state.accuracy))
.catch((e) => console.log(e));
}
// this.setState({epoch: null});
route_path = () => {
this.props.history.push('/');
}
handleSubmit(e) {
const data = { q1: this.state.query1, q2: this.state.query2 };
fetch('/*remote server*/', {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify(data),
})
.then(res => res.json())
.then(res => console.log(res));
}
render() {
return (
<div className="App">
<Container>
<Row>
<Col><Input placeholder="Class one name." onLoad={this.ticker} className="mt-5" onChange= {this.updateInput1}/></Col>
<Col><Input placeholder= "Class two name." onLoad={this.ticker} className="mt-5" onChange={this.updateInput2}/></Col>
</Row>
<Row>
<Col></Col>
<Col><Button className="mt-5" color='danger' size="lg" onClick={this.handleSubmit, this.checkEpoch}>Go</Button></Col>
<Col></Col>
</Row>
</Container>
<Route path="/hello" component={Hello}/>
</div>
);
}
}```
add_filter( 'woocommerce_order_item_needs_processing' , 'filter_woo_item_needs_processing', 10, 3 );
function filter_woo_item_needs_processing( $needs_processing, $product, $order_ID ) {
$product_type = $product->get_type();
if ( $product->is_virtual()
&& ( 'subscription' == $product_type || 'subscription_variation' == $product_type || 'variable-subscription' == $product_type ) ) {
return false;
}
return $needs_processing;
}
请记住,您必须在URL中使用http.get()
而不是var http = require('http');
setInterval(() => {
http.get('http://[app-name].herokuapp.com/');
}, 1000*60*15);
。